Day is out of range for month
DiscordChatExporterPy Version
2.8.4
Discord Version
disnake 2.10.1
Bug Description
Day is out of range for month (ValueError) for the method time_mention it only occurring with a relatively new channel that has messages only from early July onwards which has loads of timestamps in it from it being a discord verification channel so has ages of accounts in it. Other channels seem to be working fine.
at Line 187 it doesn't handle older timestamps well from <2020s, unpacking the year in the datetime_stamp as well seems to overcome this issue, i think this might be a leap year issue
Using fromtimestamp is a better solution than the current forcing of base year of 2010
timestamp = 1516897696 - 1
time_stamp = time.gmtime(timestamp)
datetime_stamp = datetime.datetime(2010, *time_stamp[1:6], tzinfo=pytz.utc)
print(f"time_stamp: {time_stamp}")
print(f"datetime_stamp: {datetime_stamp}")
>>> time_stamp: time.struct_time(tm_year=2018, tm_mon=1, tm_mday=25, tm_hour=16, tm_min=28, tm_sec=15, tm_wday=3, tm_yday=25, tm_isdst=0)
>>> datetime_stamp: 2010-01-25 16:28:15+00:00
timestamp = 1516897696 -1
time_stamp = time.gmtime(timestamp)
datetime_stamp = datetime.datetime(2010, *time_stamp[:6], tzinfo=pytz.utc)
print(f"time_stamp: {time_stamp}")
print(f"datetime_stamp: {datetime_stamp}")
>>> time_stamp: time.struct_time(tm_year=2018, tm_mon=1, tm_mday=25, tm_hour=16, tm_min=28, tm_sec=15, tm_wday=3, tm_yday=25, tm_isdst=0)
>>> datetime_stamp: 2018-01-25 16:28:15+00:00
# This gives the best solution
timestamp = 1516897696
datetime_stamp = datetime.datetime.fromtimestamp(timestamp, tz=pytz.utc)
print(f"datetime_stamp: {datetime_stamp}")
>>> datetime_stamp: 2018-01-25 16:28:16+00:00
The [:6] unpacking gives the right datetime_stamp and this fix allows my channel i was erroring with before to back up
The error:
Bug Traceback
No response
Additional Information
No response