Mercurial > hg-stable
diff mercurial/templater.py @ 36636:c6061cadb400
util: extract all date-related utils in utils/dateutil module
With this commit, util.py lose 262 lines
Note for extensions author, if this commit breaks your extension, you can pull
the step-by-step split here to help you more easily pinpoint the renaming that
broke your extension:
hg pull https://bitbucket.org/octobus/mercurial-devel/ -r ac1f6453010d
Differential Revision: https://phab.mercurial-scm.org/D2282
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Thu, 15 Feb 2018 17:18:26 +0100 |
parents | b5d39a09656a |
children | 052351e3e1cd |
line wrap: on
line diff
--- a/mercurial/templater.py Thu Feb 08 23:27:24 2018 +0530 +++ b/mercurial/templater.py Thu Feb 15 17:18:26 2018 +0100 @@ -29,6 +29,7 @@ templatekw, util, ) +from .utils import dateutil class ResourceUnavailable(error.Abort): pass @@ -649,9 +650,9 @@ fmt = evalstring(context, mapping, args[1]) try: if fmt is None: - return util.datestr(date) + return dateutil.datestr(date) else: - return util.datestr(date, fmt) + return dateutil.datestr(date, fmt) except (TypeError, ValueError): # i18n: "date" is a keyword raise error.ParseError(_("date expects a date information")) @@ -954,7 +955,7 @@ date = evalfuncarg(context, mapping, args[0]) try: - date = util.parsedate(date) + date = dateutil.parsedate(date) except AttributeError: # not str nor date tuple # i18n: "localdate" is a keyword raise error.ParseError(_("localdate expects a date information")) @@ -962,7 +963,7 @@ tzoffset = None tz = evalfuncarg(context, mapping, args[1]) if isinstance(tz, bytes): - tzoffset, remainder = util.parsetimezone(tz) + tzoffset, remainder = dateutil.parsetimezone(tz) if remainder: tzoffset = None if tzoffset is None: @@ -972,7 +973,7 @@ # i18n: "localdate" is a keyword raise error.ParseError(_("localdate expects a timezone")) else: - tzoffset = util.makedate()[1] + tzoffset = dateutil.makedate()[1] return (date[0], tzoffset) @templatefunc('max(iterable)')