UTC equivalent of time.mktime() ?

Donn Cave donn at u.washington.edu
Thu Apr 18 12:31:25 EDT 2002


Quoth Graham Ashton <gashton at cmedltd.com>:
...
| I was using strptime() and mktime() to get seconds since the epoch in
| localtime. I was trying to work out if I could do anything simpler than
| this (in which two of the "-" signs should be "+" signs):
|
| >>> def local2utc(secs):
| ...     if time.daylight:
| ...         return secs - time.timezone - time.altzone
| ...     else:
| ...         return secs - time.timezone
|
| to get the seconds since the epoch into UTC. It's looking as though the
| answer (in general) is "no".

Yes, I mean, no.

	Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list