[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). > > 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]. > For more options, visit this group at > http://groups.google.com/group/pythonireland?hl=en. > > > It's doing exactly what you asked it to do:
>>> now-week1 1555200.0 >>> (3600*24*7) 604800 >>> (now-week1) / d 2.5714285714285716 >>> (now-week1) % d 345600.0 Padraig -- 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.
