Skip to content

Commit

Permalink
Try and fix parsed
Browse files Browse the repository at this point in the history
  • Loading branch information
4Kaylum committed Jul 5, 2023
1 parent 6ded76e commit fc1b2ea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions novus/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
'format_timestamp',
'generate_repr',
'get_mime_type_for_image',
'now',
'parse_timestamp',
'try_enum',
'try_id',
Expand Down
6 changes: 5 additions & 1 deletion novus/utils/times.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
'parse_timestamp',
'format_timestamp',
'utcnow',
'now',
)


Expand Down Expand Up @@ -99,7 +100,7 @@ def parse_timestamp(timestamp: dt | str | Snowflake | None) -> DiscordDatetime |
parsed = DiscordDatetime.fromisoformat(timestamp)
elif isinstance(timestamp, dt):
parsed = DiscordDatetime.fromisoformat(timestamp.isoformat())
elif isinstance(timestamp, Snowflake):
elif hasattr(timestamp, "id"):
return (
DiscordDatetime
.fromtimestamp((timestamp.id >> 22) + 1_420_070_400_000)
Expand Down Expand Up @@ -152,3 +153,6 @@ def utcnow() -> DiscordDatetime:

ddt = DiscordDatetime.utcnow().replace(tzinfo=timezone.utc)
return ddt


now = utcnow

0 comments on commit fc1b2ea

Please sign in to comment.