tomorrow in yyyymmdd format

Gerhard Häring gerhard at bigfoot.de
Wed Jun 19 03:52:25 CEST 2002


* Sean 'Shaleh' Perry <shalehperry at attbi.com> [2002-06-18 18:38 -0700]:
> >> 
> >> 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:
> >> 
> >> >>> x = (2002, 2, 29, 0, 31, 42, 2, 170, 0)
> >> >>> time.gmtime(time.mktime(x))
> >> (2002, 3, 1, 7, 31, 42, 4, 60, 0)
> >> >>>
> > 
> > Pure luck that this works. Don't complain if it stops workin in Python
> > 2.7 and your code breaks ;-)
> > 
> 
> actually that is a function of the mktime() function in the C library which the
> python module wraps.  Based on my reading of a man page or two this behaviour
> seems guaranteed by POSIX.  Now, the assumption made is the mktime() function
> on YOUR system follows POSIX.

Fine. I've just read the Python documentation which doesn't make this
guarantee. I'll leave it to others to check if this works on win32,
MacOS, as I'm using mxDateTime for this kind of tasks, anyway.

Gerhard
-- 
mail:   gerhard <at> bigfoot <dot> de       registered Linux user #64239
web:    http://www.cs.fhm.edu/~ifw00065/    OpenPGP public key id AD24C930
public key fingerprint: 3FCC 8700 3012 0A9E B0C9  3667 814B 9CAA AD24 C930
reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))





More information about the Python-list mailing list