comparison doc/libervia-cli/common_arguments.rst @ 3609:256faf6e951f

doc (cli/common): time pattern
author Goffi <goffi@goffi.org>
date Thu, 29 Jul 2021 22:51:01 +0200
parents 6d03e8ebf1a6
children d0b66efc6c0e
comparison
equal deleted inserted replaced
3608:6d03e8ebf1a6 3609:256faf6e951f
215 Some options expect parameters, in this case they can be specified using ``=``. 215 Some options expect parameters, in this case they can be specified using ``=``.
216 216
217 e.g. specifying a template to use:: 217 e.g. specifying a template to use::
218 218
219 $ li blog get -O template --oo browser --oo template=/tmp/my_template.html 219 $ li blog get -O template --oo browser --oo template=/tmp/my_template.html
220
221 Time Pattern
222 ============
223
224 When a command expect a date or date with time argument, you can use a "time pattern" (you
225 usually see the ``TIME_PATTERN`` as name of the argument in ``--help`` message when it can
226 be used).
227
228 This is a flexible way to enter a date, you can enter a date in one of the following way:
229
230 - the string ``now`` to indicate current date and time;
231 - an absolute date using an international format. The parser know many formats (please
232 check dateutil_ package documentation to have a detail of supported formats). Please
233 note that days are specified first and that if no time zone is specified, the local
234 time zone of your computer is assumed;
235 - a relative date (or "relative delta"), see below for details on how to construct it;
236 - a reference time (``now`` or absolute date as above) followed by a relative delta. If
237 the reference time is not specified, ``now`` is used;
238
239 Time pattern is not case sensitive.
240
241 .. _dateutil: https://dateutil.readthedocs.io
242
243 Relative Delta
244 --------------
245
246 A relative delta is specified with:
247
248 - an optional direction ``+`` for times after reference time or ``-`` for time before reference time (defaulting to ``+``);
249 - a number for the quantity of units
250 - a unit (e.g. seconds or minutes), see the bellow for details
251 - the word ``ago`` which is same as using ``-`` for direction (direction and ``ago`` can't
252 be used at the same time)
253
254 Time Units
255 ----------
256
257 The singular or plural form of following units can be used:
258
259 - ``s``, ``sec``, ``second``
260 - ``m``, ``min``, ``minute``
261 - ``h``, ``hr``, ``hour``
262 - ``d``, ``day``
263 - ``w``, ``week``
264 - ``mo``, ``month``
265 - ``y``, ``yr``, ``year``
266
267 examples
268 --------
269
270 - ``2022-01-01``: first of January of 2022 at midnight
271 - ``2017-02-10T13:05:00Z``: 10th of February 2017 at 13:05 UTC
272 - ``2019-07-14 12:00:00 CET``: 14th of July 2019 at 12:00 CET
273 - ``10 min ago``: current time minus 10 minutes
274 - ``now - 10 m``: same as above (current time minus 10 minutes)
275 - ``07/08/2021 +5 hours``: 7 August 2021 at midnight (local time of the computer) + 5
276 hours, i.e. 5 in the morning at local time.
277