mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-11 09:13:57 -04:00
Fix incorrect docs for date_arithmetic()
This commit is contained in:
parent
75139040a0
commit
69eac37671
@ -398,7 +398,7 @@ In `GPM` the functions described in `Single Function Mode` all require an additi
|
|||||||
* ``w``: add ``v`` weeks to ``date``
|
* ``w``: add ``v`` weeks to ``date``
|
||||||
* ``y``: add ``v`` years to ``date``, where a year is 365 days.
|
* ``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.
|
* ``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.
|
* ``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>`.
|
* ``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>`.
|
||||||
|
@ -1629,7 +1629,7 @@ class BuiltinDateArithmetic(BuiltinFormatterFunction):
|
|||||||
"w: add 'v' weeks to 'date' "
|
"w: add 'v' weeks to 'date' "
|
||||||
"y: add 'v' years to 'date', where a year is 365 days. "
|
"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 "
|
"Example: '1s3d-1m' will add 1 second, add 3 days, and subtract 1 "
|
||||||
"month from 'date'.")
|
"minute from 'date'.")
|
||||||
|
|
||||||
calc_ops = {
|
calc_ops = {
|
||||||
's': lambda v: timedelta(seconds=v),
|
's': lambda v: timedelta(seconds=v),
|
||||||
@ -1638,7 +1638,7 @@ class BuiltinDateArithmetic(BuiltinFormatterFunction):
|
|||||||
'd': lambda v: timedelta(days=v),
|
'd': lambda v: timedelta(days=v),
|
||||||
'w': lambda v: timedelta(weeks=v),
|
'w': lambda v: timedelta(weeks=v),
|
||||||
'y': lambda v: timedelta(days=v * 365),
|
'y': lambda v: timedelta(days=v * 365),
|
||||||
}
|
}
|
||||||
|
|
||||||
def evaluate(self, formatter, kwargs, mi, locals, date, calc_spec, fmt=None):
|
def evaluate(self, formatter, kwargs, mi, locals, date, calc_spec, fmt=None):
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user