50 "Mon Sep 04 15:13:13 2006 0700".""" |
50 "Mon Sep 04 15:13:13 2006 0700".""" |
51 if not (1 <= len(args) <= 2): |
51 if not (1 <= len(args) <= 2): |
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 = evalfuncarg(context, mapping, args[0]) |
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: |
61 if fmt is None: |
60 if fmt is None: |
62 return dateutil.datestr(date) |
61 return dateutil.datestr(date) |
63 else: |
62 else: |
64 return dateutil.datestr(date, fmt) |
63 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): |
70 """Construct a dict from key-value pairs. A key may be omitted if |
68 """Construct a dict from key-value pairs. A key may be omitted if |
71 a value expression can provide an unambiguous name.""" |
69 a value expression can provide an unambiguous name.""" |