diff libervia/backend/tools/common/date_utils.py @ 4384:33468e175ade

backend: various fixes, and type hints improvments.
author Goffi <goffi@goffi.org>
date Sun, 03 Aug 2025 23:36:22 +0200
parents 0d7bb4df2343
children
line wrap: on
line diff
--- a/libervia/backend/tools/common/date_utils.py	Sun Aug 03 23:35:21 2025 +0200
+++ b/libervia/backend/tools/common/date_utils.py	Sun Aug 03 23:36:22 2025 +0200
@@ -61,12 +61,13 @@
 TZ_LOCAL = tz.gettz()
 
 
-def date_parse(value, default_tz=TZ_UTC):
+def date_parse(value: str, default_tz: datetime.tzinfo=TZ_UTC) -> int:
     """Parse a date and return corresponding unix timestamp
 
-    @param value(unicode): date to parse, in any format supported by parser
-    @param default_tz(datetime.tzinfo): default timezone
-    @return (int): timestamp
+    @param value: date to parse, in any format supported by parser
+    @param default_tz: default timezone
+    @return: timestamp
+    @raise ValueError: Date can't be parsed.
     """
     value = str(value).strip()
     dayfirst = False if YEAR_FIRST_RE.match(value) else True