Commit graph libervia-backend/sat/tools/common/date_utils.py
Author SHA1 Message Date
Goffi
093b9d83bc tools (common/date_utils) handle timestamp and in + delta2human:
regex used to parse datetimes has been improved to handle a unix time (which can be used
with `+ <delta>` or `- <delta>`), and the `in <delta>` (e.g. `in 6 days`).

`DEFAULT_DATETIME` has been removed as dateutil use current date by default, which is the
expected behaviour.

Add `delta2human` method which convert the difference of 2 unix times to a human friendly
approximate text.

rel 372
2022-09-22 00:01:48 +02:00
Goffi
436696f28c merge branche "@" 2021-08-27 14:51:40 +02:00
Goffi
506368275a tools (common/date_utils): parse now alone (when used without relative delta) 2021-08-27 14:48:38 +02:00
Goffi
aab8a38836 tools (common/date_utils): accept more units (shortcuts) + fix timezone when date with relative delta is used 2021-07-29 22:51:01 +02:00
Goffi
af053c5f34 tools (common/date_utils): fix date_only for short, long and full format 2021-05-01 18:36:13 +02:00
Goffi
dc86957043 date update 2021-03-19 15:45:14 +01:00
Goffi
e1a44cf4e4 fixed shebangs 2020-01-29 10:07:00 +01:00
Goffi
a39349fe64 dates update 2020-01-29 09:50:54 +01:00
Goffi
fbfe96c505 Python 3 port:
/!\ this is a huge commit
/!\ starting from this commit, SàT is needs Python 3.6+
/!\ SàT maybe be instable or some feature may not work anymore, this will improve with time

This patch port backend, bridge and frontends to Python 3.

Roughly this has been done this way:

- 2to3 tools has been applied (with python 3.7)
- all references to python2 have been replaced with python3 (notably shebangs)
- fixed files not handled by 2to3 (notably the shell script)
- several manual fixes
- fixed issues reported by Python 3 that where not handled in Python 2
- replaced "async" with "async_" when needed (it's a reserved word from Python 3.7)
- replaced zope's "implements" with @implementer decorator
- temporary hack to handle data pickled in database, as str or bytes may be returned,
  to be checked later
- fixed hash comparison for password
- removed some code which is not needed anymore with Python 3
- deactivated some code which needs to be checked (notably certificate validation)
- tested with jp, fixed reported issues until some basic commands worked
- ported Primitivus (after porting dependencies like urwid satext)
- more manual fixes
2019-08-13 19:08:41 +02:00
Goffi
309e5eebb9 tools(common/date_utils): fixed order on year first + set default date for date_parse 2019-03-01 15:35:55 +01:00
Goffi
5827849863 tools (common): fixed dateutil.parser import 2019-02-02 01:12:54 +01:00
Goffi
8e338bf913 date update 2019-01-12 12:25:31 +01:00
Goffi
4b81275fdf tools (common/date_utils): date_parse_ext + timezone handling:
- new date_parse_ext method parse a date where relative informations can be added. e.g.: "1 week ago", "now - 2 days", "01/01/01 01:01 + 3 hours".
- new TZ_UTC and TZ_LOCAL constants can be used to use UTC time or local time zone.
- date_parse* can now use a default_tz, which will be used if timezone if not specified in date format (default UTC).
- tz_info can now be used in date_format to format the time in given timezone (default: UTC).
2018-12-01 10:40:19 +01:00
Goffi
744cb0c503 code style reformatting using black 2018-06-27 20:14:46 +02:00
Goffi
0242772939 tools (date_utils): moved date_parse to common.date_utils, because it can be used in frontends 2018-06-21 01:21:44 +02:00
Goffi
785af76bc0 tools (common): moved date_fmt function from template filters to new date_utils module, so it can be used everywhere. 2018-06-01 12:04:06 +02:00