Skip to content

Commit

Permalink
Revert "Some more utc-code cleanup."
Browse files Browse the repository at this point in the history
This reverts commit 7a2095f.
  • Loading branch information
titov-vv committed May 7, 2024
1 parent 0e40bf4 commit 353f4a3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions jal/db/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,20 @@ def db_row2dict(model, row) -> dict:
# Returns timestamp of the first second of the year of given timestamp
def year_begin(timestamp: int) -> int:
begin = datetime.fromtimestamp(timestamp, tz=timezone.utc).replace(month=1, day=1, hour=0, minute=0, second=0)
return int(begin.timestamp())
return int(begin.replace(tzinfo=timezone.utc).timestamp())

# Returns timestamp of the last second of the year of given timestamp
def year_end(timestamp: int) -> int:
end = datetime.fromtimestamp(timestamp, tz=timezone.utc).replace(month=1, day=1, hour=0, minute=0, second=0)
end = end.replace(year=end.year + 1) - timedelta(seconds=1)
return int(end.timestamp())
return int(end.replace(tzinfo=timezone.utc).timestamp())

# Returns current timestamp
def now_ts() -> int:
return int(datetime.now(tz=timezone.utc).timestamp())
return int(datetime.now().replace(tzinfo=timezone.utc).timestamp())

# Returns timestamp of the last second of the day of given timestamp
def day_end(timestamp: int) -> int:
end = datetime.fromtimestamp(timestamp, tz=timezone.utc).replace(hour=23, minute=59, second=59)
return int(end.timestamp())
return int(end.replace(tzinfo=timezone.utc).timestamp())
# -------------------------------------------------------------------------------------------------------------------

0 comments on commit 353f4a3

Please sign in to comment.