Mercurial > public > mercurial-scm > hg
comparison mercurial/util.py @ 3256:e5c9a084ffe3
util.strdate: assume local time when no timezone specified
author | Jose M. Prieto <jmprieto@gmx.net> |
---|---|
date | Tue, 03 Oct 2006 12:33:18 +0200 |
parents | e96d2956eb4a |
children | c9cd63a6fce9 |
comparison
equal
deleted
inserted
replaced
3255:e96d2956eb4a | 3256:e5c9a084ffe3 |
---|---|
907 if hastimezone(string): | 907 if hastimezone(string): |
908 date, tz = string[:-6], string[-5:] | 908 date, tz = string[:-6], string[-5:] |
909 tz = int(tz) | 909 tz = int(tz) |
910 offset = - 3600 * (tz / 100) - 60 * (tz % 100) | 910 offset = - 3600 * (tz / 100) - 60 * (tz % 100) |
911 else: | 911 else: |
912 date, offset = string, 0 | 912 date, offset = string, None |
913 localunixtime = int(calendar.timegm(time.strptime(date, format))) | 913 timetuple = time.strptime(date, format) |
914 unixtime = localunixtime + offset | 914 localunixtime = int(calendar.timegm(timetuple)) |
915 if offset is None: | |
916 # local timezone | |
917 unixtime = int(time.mktime(timetuple)) | |
918 offset = unixtime - localunixtime | |
919 else: | |
920 unixtime = localunixtime + offset | |
915 return unixtime, offset | 921 return unixtime, offset |
916 | 922 |
917 def parsedate(string, formats=None): | 923 def parsedate(string, formats=None): |
918 """parse a localized time string and return a (unixtime, offset) tuple. | 924 """parse a localized time string and return a (unixtime, offset) tuple. |
919 The date may be a "unixtime offset" string or in one of the specified | 925 The date may be a "unixtime offset" string or in one of the specified |