tomorrow in yyyymmdd format

Ralph Corderoy ralph at inputplus.co.uk
Wed Aug 14 15:40:03 CEST 2002


Hi Conrad,

> > > > > Sure there is :-) time.mktime() can take a "malformed" time
> > > > > tuple and do something sensible with it. You can therefore get
> > > > > a time tuple from gmtime, add one to the day position and call
> > > > > time.mktime() on the result:
>
> from time import *
> one_day = 60*60*24                       # number of seconds in day
>    # make a julian for tomorrow -
>    # note: depending on what you want be careful around midnight!
> tomorrow = mktime(localtime()) + one_day

What if now is 00:00 and today has a leap second or two?  60*60*24
doesn't reach tomorrow.

Add one to the day argument to mktime().  That's why POSIX allowed you
to do it and it is the normal way to do this kind of thing in C
programs.  A lot of the complexity is hidden.

Cheers,


Ralph.




More information about the Python-list mailing list