Fix incorrect docs for date_arithmetic()

This commit is contained in:
Kovid Goyal 2021-06-04 05:01:30 +05:30
parent 75139040a0
commit 69eac37671
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 3 additions and 3 deletions

View File

@ -398,7 +398,7 @@ In `GPM` the functions described in `Single Function Mode` all require an additi
* ``w``: add ``v`` weeks to ``date``
* ``y``: add ``v`` years to ``date``, where a year is 365 days.
Example: ``'1s3d-1m'`` will add 1 second, add 3 days, and subtract 1 month from ``date``.
Example: ``'1s3d-1m'`` will add 1 second, add 3 days, and subtract 1 minute from ``date``.
* ``days_between(date1, date2)`` -- return the number of days between ``date1`` and ``date2``. The number is positive if ``date1`` is greater than ``date2``, otherwise negative. If either ``date1`` or ``date2`` are not dates, the function returns the empty string.
* ``divide(x, y)`` -- returns ``x / y``. Throws an exception if either ``x`` or ``y`` are not numbers. This function can usually be replaced by the ``/`` operator.
* ``eval(string)`` -- evaluates the string as a program, passing the local variables. This permits using the template processor to construct complex results from local variables. In :ref:`Template Program Mode <template_mode>`, because the `{` and `}` characters are interpreted before the template is evaluated you must use `[[` for the `{` character and `]]` for the ``}`` character. They are converted automatically. Note also that prefixes and suffixes (the `|prefix|suffix` syntax) cannot be used in the argument to this function when using :ref:`Template Program Mode <template_mode>`.

View File

@ -1629,7 +1629,7 @@ class BuiltinDateArithmetic(BuiltinFormatterFunction):
"w: add 'v' weeks to 'date' "
"y: add 'v' years to 'date', where a year is 365 days. "
"Example: '1s3d-1m' will add 1 second, add 3 days, and subtract 1 "
"month from 'date'.")
"minute from 'date'.")
calc_ops = {
's': lambda v: timedelta(seconds=v),
@ -1638,7 +1638,7 @@ class BuiltinDateArithmetic(BuiltinFormatterFunction):
'd': lambda v: timedelta(days=v),
'w': lambda v: timedelta(weeks=v),
'y': lambda v: timedelta(days=v * 365),
}
}
def evaluate(self, formatter, kwargs, mi, locals, date, calc_spec, fmt=None):
try: