Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/util.py @ 13063:e98581d44f0b stable
makedate: abort on negative timestamps (issue2513)
catches weird clock settings
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Wed, 24 Nov 2010 19:31:43 +0100 |
parents | e1002cf9fe54 |
children | adff480db558 |
comparison
equal
deleted
inserted
replaced
13062:e1002cf9fe54 | 13063:e98581d44f0b |
---|---|
1013 lt = time.localtime() | 1013 lt = time.localtime() |
1014 if lt[8] == 1 and time.daylight: | 1014 if lt[8] == 1 and time.daylight: |
1015 tz = time.altzone | 1015 tz = time.altzone |
1016 else: | 1016 else: |
1017 tz = time.timezone | 1017 tz = time.timezone |
1018 return time.mktime(lt), tz | 1018 t = time.mktime(lt) |
1019 if t < 0: | |
1020 hint = _("check your clock") | |
1021 raise Abort(_("negative timestamp: %d") % t, hint=hint) | |
1022 return t, tz | |
1019 | 1023 |
1020 def datestr(date=None, format='%a %b %d %H:%M:%S %Y %1%2'): | 1024 def datestr(date=None, format='%a %b %d %H:%M:%S %Y %1%2'): |
1021 """represent a (unixtime, offset) tuple as a localized time. | 1025 """represent a (unixtime, offset) tuple as a localized time. |
1022 unixtime is seconds since the epoch, and offset is the time zone's | 1026 unixtime is seconds since the epoch, and offset is the time zone's |
1023 number of seconds away from UTC. if timezone is false, do not | 1027 number of seconds away from UTC. if timezone is false, do not |