Manually calculate millisceond epoch rather than bitshifting
Implementation by Danny.
This commit is contained in:
parent
4ab9c874f8
commit
cfc2e47b4f
@ -25,6 +25,7 @@ DEALINGS IN THE SOFTWARE.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import datetime
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
@ -514,10 +515,11 @@ class Message:
|
|||||||
"Roses are red, violets are blue, {0} joined this server with you",
|
"Roses are red, violets are blue, {0} joined this server with you",
|
||||||
]
|
]
|
||||||
|
|
||||||
# we can't use snowflake_time here because we need the millisecond
|
# manually reconstruct the epoch with millisecond precision, because
|
||||||
# precision from snowflakes in order to calculate the correct format
|
# datetime.datetime.timestamp() doesn't return the exact posix
|
||||||
index = ((self.id >> 22) + utils.DISCORD_EPOCH) % len(formats)
|
# timestamp with the precision that we need
|
||||||
return formats[index].format(self.author.name)
|
created_at_ms = int((self.created_at - datetime.datetime(1970, 1, 1)).total_seconds() * 1000)
|
||||||
|
return formats[created_at_ms % len(formats)].format(self.author.name)
|
||||||
|
|
||||||
if self.type is MessageType.call:
|
if self.type is MessageType.call:
|
||||||
# we're at the call message type now, which is a bit more complicated.
|
# we're at the call message type now, which is a bit more complicated.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user