comparison mercurial/templatefuncs.py @ 38297:8d6109b49b31

templater: introduce a wrapper for date tuple (BC) Strictly speaking, this is BC, but I believe the original string format (str(float(unixtime)) + str(int(tzoffset))) was just plain wrong.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 24 Mar 2018 17:54:02 +0900
parents fb874fc1d9b4
children 4b73f316ba0e
comparison
equal deleted inserted replaced
38296:e72697893c93 38297:8d6109b49b31
389 except (TypeError, ValueError): 389 except (TypeError, ValueError):
390 # i18n: "localdate" is a keyword 390 # i18n: "localdate" is a keyword
391 raise error.ParseError(_("localdate expects a timezone")) 391 raise error.ParseError(_("localdate expects a timezone"))
392 else: 392 else:
393 tzoffset = dateutil.makedate()[1] 393 tzoffset = dateutil.makedate()[1]
394 return (date[0], tzoffset) 394 return templateutil.date((date[0], tzoffset))
395 395
396 @templatefunc('max(iterable)') 396 @templatefunc('max(iterable)')
397 def max_(context, mapping, args, **kwargs): 397 def max_(context, mapping, args, **kwargs):
398 """Return the max of an iterable""" 398 """Return the max of an iterable"""
399 if len(args) != 1: 399 if len(args) != 1:
459 raise error.ParseError(_("obsfatedate expects one argument")) 459 raise error.ParseError(_("obsfatedate expects one argument"))
460 460
461 markers = evalfuncarg(context, mapping, args[0]) 461 markers = evalfuncarg(context, mapping, args[0])
462 462
463 try: 463 try:
464 # TODO: maybe this has to be a wrapped list of date wrappers?
464 data = obsutil.markersdates(markers) 465 data = obsutil.markersdates(markers)
465 return templateutil.hybridlist(data, name='date', fmt='%d %d') 466 return templateutil.hybridlist(data, name='date', fmt='%d %d')
466 except (TypeError, KeyError): 467 except (TypeError, KeyError):
467 # i18n: "obsfatedate" is a keyword 468 # i18n: "obsfatedate" is a keyword
468 errmsg = _("obsfatedate first argument should be an iterable") 469 errmsg = _("obsfatedate first argument should be an iterable")