Mercurial > public > mercurial-scm > hg-stable
diff mercurial/util.py @ 3255:e96d2956eb4a
util.strdate: compute timestamp using UTC, not local timezone
author | Jose M. Prieto <jmprieto@gmx.net> |
---|---|
date | Tue, 03 Oct 2006 12:33:14 +0200 |
parents | 7492b33bdd9f |
children | e5c9a084ffe3 |
line wrap: on
line diff
--- a/mercurial/util.py Tue Oct 03 16:36:40 2006 -0700 +++ b/mercurial/util.py Tue Oct 03 12:33:14 2006 +0200 @@ -15,7 +15,7 @@ from i18n import gettext as _ from demandload import * demandload(globals(), "cStringIO errno getpass popen2 re shutil sys tempfile") -demandload(globals(), "os threading time") +demandload(globals(), "os threading time calendar") # used by parsedate defaultdateformats = ('%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M', @@ -903,14 +903,16 @@ (string[-5] == '+' or string[-5] == '-') and string[-6].isspace()) + # NOTE: unixtime = localunixtime + offset if hastimezone(string): date, tz = string[:-6], string[-5:] tz = int(tz) offset = - 3600 * (tz / 100) - 60 * (tz % 100) else: date, offset = string, 0 - when = int(time.mktime(time.strptime(date, format))) + offset - return when, offset + localunixtime = int(calendar.timegm(time.strptime(date, format))) + unixtime = localunixtime + offset + return unixtime, offset def parsedate(string, formats=None): """parse a localized time string and return a (unixtime, offset) tuple.