Skip to content

Commit

Permalink
Better handling of 2yk35/38 issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
funilrys committed Feb 26, 2025
1 parent c8f74c6 commit eec9158
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions PyFunceble/dataset/sql_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,11 @@ def add(self, row) -> "SQLDBDatasetBase":
if "expiration_date" not in row and "epoch" not in row:
raise exception

y2k38_limit = datetime(2035, 12, 31, 0, 0)
y2k38_limit = datetime(2035, 12, 31, 0, 0, tzinfo=timezone.utc)
new_date = datetime.fromtimestamp(float(row["epoch"]), timezone.utc)
new_date -= new_date - y2k38_limit

if new_date >= y2k38_limit:
new_date = y2k38_limit

row["epoch"] = new_date.timestamp()
row["expiration_date"] = new_date.strftime("%d-%b-%Y")
Expand Down

0 comments on commit eec9158

Please sign in to comment.