mercurial/utils/dateutil.py
changeset 45942 89a2afe31e82
parent 43781 b65bd4b61d78
child 46419 6894c9ef4dcd
equal deleted inserted replaced
45941:346af7687c6f 45942:89a2afe31e82
    51     b'%I:%M:%S%p',
    51     b'%I:%M:%S%p',
    52     b'%H:%M',
    52     b'%H:%M',
    53     b'%I:%M%p',
    53     b'%I:%M%p',
    54 )
    54 )
    55 
    55 
    56 extendeddateformats = defaultdateformats + (b"%Y", b"%Y-%m", b"%b", b"%b %Y",)
    56 extendeddateformats = defaultdateformats + (
       
    57     b"%Y",
       
    58     b"%Y-%m",
       
    59     b"%b",
       
    60     b"%b %Y",
       
    61 )
    57 
    62 
    58 
    63 
    59 def makedate(timestamp=None):
    64 def makedate(timestamp=None):
    60     '''Return a unix timestamp (or the current time) as a (unixtime,
    65     """Return a unix timestamp (or the current time) as a (unixtime,
    61     offset) tuple based off the local timezone.'''
    66     offset) tuple based off the local timezone."""
    62     if timestamp is None:
    67     if timestamp is None:
    63         timestamp = time.time()
    68         timestamp = time.time()
    64     if timestamp < 0:
    69     if timestamp < 0:
    65         hint = _(b"check your clock")
    70         hint = _(b"check your clock")
    66         raise error.Abort(_(b"negative timestamp: %d") % timestamp, hint=hint)
    71         raise error.Abort(_(b"negative timestamp: %d") % timestamp, hint=hint)
   113     return datestr(date, format=b'%Y-%m-%d')
   118     return datestr(date, format=b'%Y-%m-%d')
   114 
   119 
   115 
   120 
   116 def parsetimezone(s):
   121 def parsetimezone(s):
   117     """find a trailing timezone, if any, in string, and return a
   122     """find a trailing timezone, if any, in string, and return a
   118        (offset, remainder) pair"""
   123     (offset, remainder) pair"""
   119     s = pycompat.bytestr(s)
   124     s = pycompat.bytestr(s)
   120 
   125 
   121     if s.endswith(b"GMT") or s.endswith(b"UTC"):
   126     if s.endswith(b"GMT") or s.endswith(b"UTC"):
   122         return 0, s[:-3].rstrip()
   127         return 0, s[:-3].rstrip()
   123 
   128