On Apr 17, 6:41 am, [EMAIL PROTECTED] (Alex Martelli) wrote: > edfialk <[EMAIL PROTECTED]> wrote: > > Hi, does anyone happen to know of ascriptthat would return the > > number ofsecondsin amonthif I give it amonthand a year? > > > My python is a little weak, but if anyone could offer some suggestions > > I think I could handle it myself, or if anyone happens to know of a > >scriptalready written that performs this I would be extremely > > grateful. > > import calendar > > def seconds_in_month(month, year): > nomatter, daysinmonth = calendar.monthrange(year,month) > return daysinmonth * 24 * 60 * 60 > > Alex
That works if you define the number of seconds in a month a the number of days * 24 * 60 * 60. If you have DST then that's not always the truth. The difference in seconds (clock time) is according to your example, but the number of seconds that passed during the month differs. Not sure which one was requested in the original post though. -- http://mail.python.org/mailman/listinfo/python-list