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 5963ec05ca - Show all commits

View File

@@ -1034,19 +1034,21 @@ def format_dt(dt: datetime.datetime, /, style: Optional[TimestampStyle] = None)
def generate_snowflake(dt: datetime.datetime) -> int:
"""
-----------
dt: :class:`datetime.datetime`
A datetime object to convert to a snowflake.
If naive, the timezone is assumed to be local time.
Returns :class:`int` as The snowflake representing the time given.
"""
##"""
#-----------
#dt: :class:`datetime.datetime`
#A datetime object to convert to a snowflake.
#If naive, the timezone is assumed to be local time.
#Returns :class:`int` as The snowflake representing the time given.
#"""
return int(dt.timestamp() * 1000 - DISCORD_EPOCH) << 22 | 0x3fffff
def quick_snowflake() -> int:
""":class:`int` Returns with The snowflake representing a snowflake from the immediate time.
"""
#""":class:`int` Returns with The snowflake representing a snowflake from the immediate time.
#"""
return int(utcnow().timestamp() * 1000 - DISCORD_EPOCH) << 22 | 0x3fffff