Add support for JS-style 13-char timestamps to Cacher

This commit is contained in:
rlaphoenix 2023-03-13 22:48:08 +00:00
parent ddf1c519e0
commit 36c530ccc6
1 changed files with 2 additions and 0 deletions

View File

@ -150,6 +150,8 @@ class Cacher:
except ValueError: except ValueError:
timestamp = float(timestamp) timestamp = float(timestamp)
try: try:
if len(str(int(timestamp))) == 13: # JS-style timestamp
timestamp /= 1000
timestamp = datetime.fromtimestamp(timestamp) timestamp = datetime.fromtimestamp(timestamp)
except ValueError: except ValueError:
raise ValueError(f"Unrecognized Timestamp value {timestamp!r}") raise ValueError(f"Unrecognized Timestamp value {timestamp!r}")