This adds more accurate utils for generating a snowflake from datetime. #91

Open
JDJGInc wants to merge 18 commits from JDJGInc/2.0 into 2.0
Showing only changes of commit d2837a34f3 - Show all commits

View File

@@ -85,7 +85,6 @@ __all__ = (
"as_chunks",
"format_dt",
"generate_snowflake",
"quick_snowflake"
)
DISCORD_EPOCH = 1420070400000
@@ -1047,7 +1046,7 @@ def generate_snowflake(dt: Optional[datetime.datetime] = None) -> int:
:class:`int`
The snowflake representing the time given.
"""
dt = dt or utcnow()
return int(dt.timestamp() * 1000 - DISCORD_EPOCH) << 22 | 0x3fffff