Show More
@@ -52,18 +52,16 b' def date(context, mapping, args):' | |||||
52 | # i18n: "date" is a keyword |
|
52 | # i18n: "date" is a keyword | |
53 | raise error.ParseError(_("date expects one or two arguments")) |
|
53 | raise error.ParseError(_("date expects one or two arguments")) | |
54 |
|
54 | |||
55 |
date = eval |
|
55 | date = evaldate(context, mapping, args[0], | |
|
56 | # i18n: "date" is a keyword | |||
|
57 | _("date expects a date information")) | |||
56 | fmt = None |
|
58 | fmt = None | |
57 | if len(args) == 2: |
|
59 | if len(args) == 2: | |
58 | fmt = evalstring(context, mapping, args[1]) |
|
60 | fmt = evalstring(context, mapping, args[1]) | |
59 | try: |
|
|||
60 |
|
|
61 | if fmt is None: | |
61 |
|
|
62 | return dateutil.datestr(date) | |
62 |
|
|
63 | else: | |
63 |
|
|
64 | return dateutil.datestr(date, fmt) | |
64 | except (TypeError, ValueError): |
|
|||
65 | # i18n: "date" is a keyword |
|
|||
66 | raise error.ParseError(_("date expects a date information")) |
|
|||
67 |
|
65 | |||
68 | @templatefunc('dict([[key=]value...])', argspec='*args **kwargs') |
|
66 | @templatefunc('dict([[key=]value...])', argspec='*args **kwargs') | |
69 | def dict_(context, mapping, args): |
|
67 | def dict_(context, mapping, args): |
@@ -330,6 +330,10 b' def unwrapdate(thing, err=None):' | |||||
330 | return dateutil.parsedate(thing) |
|
330 | return dateutil.parsedate(thing) | |
331 | except AttributeError: |
|
331 | except AttributeError: | |
332 | raise error.ParseError(err or _('not a date tuple nor a string')) |
|
332 | raise error.ParseError(err or _('not a date tuple nor a string')) | |
|
333 | except error.ParseError: | |||
|
334 | if not err: | |||
|
335 | raise | |||
|
336 | raise error.ParseError(err) | |||
333 |
|
337 | |||
334 | def evalinteger(context, mapping, arg, err=None): |
|
338 | def evalinteger(context, mapping, arg, err=None): | |
335 | return unwrapinteger(evalrawexp(context, mapping, arg), err) |
|
339 | return unwrapinteger(evalrawexp(context, mapping, arg), err) |
General Comments 0
You need to be logged in to leave comments.
Login now