Thanks Nick and Padraig, Stupid mistake on my part.
J On Dec 8, 2:04 pm, Nick Johnson <[email protected]> wrote: > Hi John, > > On Tue, Dec 8, 2009 at 1:57 PM, [email protected] > <[email protected]>wrote: > > > I'm trying to use Python's Modulus operator and getting weird > > results. > > > I'm trying to calculate the week that a date falls on. > > > My first week, week1 is: > > > week1 = time.mktime(time.strptime("6 Jan 10", "%d %b %y")) > > > My test date is: > > now = time.mktime(time.strptime("24 Jan 10", "%d %b %y")) > > > (now - week1) % (3600*24*7) should result in c. 2.5 (week 3). > > The modulo operator here will return the second of the week, not the week > number itself. You want (now - week1) / (3600*24*7). > > -Nick > > > > > Instead I'm getting a result of: > > In [45]: (now - week1) % (3600*24*7) > > Out[45]: 345600.0 > > > I'm using Python 2.6.2 (r262:71600, Aug 21 2009, 12:23:57) (default > > Fedora 12 RPM) > > > Is this like the from __future__ import division issue? > > > TIA, > > John > > > -- > > > You received this message because you are subscribed to the Google Groups > > "Python Ireland" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]<pythonireland%[email protected]> > > . > > For more options, visit this group at > >http://groups.google.com/group/pythonireland?hl=en. -- You received this message because you are subscribed to the Google Groups "Python Ireland" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/pythonireland?hl=en.
