Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/utils/dateutil.py @ 45957:89a2afe31e82
formating: upgrade to black 20.8b1
This required a couple of small tweaks to un-confuse black, but now it
works. Big formatting changes come from:
* Dramatically improved collection-splitting logic upstream
* Black having a strong (correct IMO) opinion that """ is better than '''
Differential Revision: https://phab.mercurial-scm.org/D9430
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Fri, 27 Nov 2020 17:03:29 -0500 |
parents | b65bd4b61d78 |
children | 6894c9ef4dcd |
comparison
equal
deleted
inserted
replaced
45956:346af7687c6f | 45957: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 |