Skip to content

Commit

Permalink
Create datetime utils; reorg layout
Browse files Browse the repository at this point in the history
  • Loading branch information
chanhosuh committed Oct 18, 2023
1 parent b859c05 commit 6d83be5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
File renamed without changes.
21 changes: 21 additions & 0 deletions curvesim/utils/datetime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from datetime import datetime, timezone


def now():
"""
Customized version of `datetime.datetime.now` to ensure
UTC timezone and format.
"""
utc_dt = datetime.now(timezone.utc).replace(
hour=0, minute=0, second=0, microsecond=0
)
return utc_dt


def fromtimestamp(timestamp):
"""
Customized version of `datetime.datetime.fromtimestamp` to ensure
UTC timezone and format.
"""
utc_timestamp = datetime.fromtimestamp(timestamp, tz=timezone.utc)
return utc_timestamp

0 comments on commit 6d83be5

Please sign in to comment.