Mercurial > libervia-backend
comparison sat/tools/common/date_utils.py @ 3518:b258dce27d6d
tools (common/date_utils): fix `date_only` for `short`, `long` and `full` format
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 01 May 2021 18:36:13 +0200 |
parents | be6d91572633 |
children | ab1fe6b25631 025ea418032f |
comparison
equal
deleted
inserted
replaced
3517:8508fab9bcc2 | 3518:b258dce27d6d |
---|---|
148 if fmt == "relative": | 148 if fmt == "relative": |
149 delta = timestamp - time.time() | 149 delta = timestamp - time.time() |
150 return dates.format_timedelta( | 150 return dates.format_timedelta( |
151 delta, granularity="minute", add_direction=True, locale=locale_str | 151 delta, granularity="minute", add_direction=True, locale=locale_str |
152 ) | 152 ) |
153 elif fmt in ("short", "long"): | 153 elif fmt in ("short", "long", "full"): |
154 if date_only: | 154 if date_only: |
155 dt = datetime.fromtimestamp(timestamp, tz_info) | 155 dt = datetime.datetime.fromtimestamp(timestamp, tz_info) |
156 return dates.format_date(dt, format=fmt, locale=locale_str) | 156 return dates.format_date(dt, format=fmt, locale=locale_str) |
157 else: | 157 else: |
158 return dates.format_datetime(timestamp, format=fmt, locale=locale_str, | 158 return dates.format_datetime(timestamp, format=fmt, locale=locale_str, |
159 tzinfo=tz_info) | 159 tzinfo=tz_info) |
160 elif fmt == "iso": | 160 elif fmt == "iso": |