mirror of
https://github.com/ArchiveBox/ArchiveBox
synced 2024-11-22 20:23:12 +00:00
add note about saving timestamp strings independently
This commit is contained in:
parent
6d92784dbb
commit
880b425df6
1 changed files with 11 additions and 0 deletions
|
@ -373,6 +373,11 @@ def parse_date(date: Any) -> Optional[datetime]:
|
|||
# anything from hours to decades, depending on which app, OS,
|
||||
# and sytem time configuration was used for the original timestamp
|
||||
# more info: https://github.com/pirate/ArchiveBox/issues/119
|
||||
|
||||
# Note: always always always store the original timestamp string
|
||||
# somewhere indepentendly of the parsed datetime, so that later
|
||||
# bugs dont repeatedly misparse and rewrite increasingly worse dates.
|
||||
# the correct date can always be re-derived from the timestamp str
|
||||
timestamp = float(date)
|
||||
|
||||
EARLIEST_POSSIBLE = 473403600.0 # 1985
|
||||
|
@ -389,6 +394,12 @@ def parse_date(date: Any) -> Optional[datetime]:
|
|||
# number is microseconds
|
||||
return datetime.fromtimestamp(timestamp / (1000*1000))
|
||||
|
||||
else:
|
||||
# continue to the end and raise a parsing failed error.
|
||||
# we dont want to even attempt parsing timestamp strings that
|
||||
# arent within these ranges
|
||||
pass
|
||||
|
||||
if '-' in date:
|
||||
try:
|
||||
return datetime.fromisoformat(date)
|
||||
|
|
Loading…
Reference in a new issue