script for seconds in given month?
pythoncurious at gmail.com
pythoncurious at gmail.com
Mon Apr 16 12:56:44 EDT 2007
On Apr 16, 6:22 pm, "edfialk" <edfi... at gmail.com> wrote:
> Hi, does anyone happen to know of a script that would return the
> number of seconds in a month if I give it a month and a year?
>
something like this might work, it should event handle DST correctly.
You could read up on mktime() if you want to make sure.
from time import mktime
def secondsInMonth(year, month):
s1 = mktime((year,month,1,0,0,0,0,0,-1))
s2 = mktime((year,month+1,1,0,0,0,0,0,-1))
return s2-s1
/Matt
More information about the Python-list
mailing list