Skip to content

Commit 2eef35d

Browse files
authored
fix: adjust astimezone checks (#1703)
1 parent d65e2a0 commit 2eef35d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

interactions/models/discord/timestamp.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,15 @@ def astimezone(self, tz: tzinfo | None = None) -> "Timestamp":
9999
if self.year > 1970 or (self.year == 1970 and (self.month > 1 or self.day > 1)):
100100
return super().astimezone(tz)
101101

102-
if self.year < 1969 or self.month < 12 or self.day < 31:
102+
if self.year < 1969 or (self.year == 1969 and (self.month < 12 or self.day < 31)):
103103
# windows kind of breaks down for dates before unix time
104104
# technically this is solvable, but it's not worth the effort
105105
# also, again, this is a loose bound, but it's good enough for our purposes
106106
raise ValueError("astimezone with no arguments is not supported for dates before Unix Time on Windows.")
107107

108+
if tz:
109+
return self.replace(tzinfo=tz)
110+
108111
# to work around the issue to some extent, we'll use a timestamp with a date
109112
# that doesn't trigger the bug, and use the timezone from it to modify this
110113
# timestamp

0 commit comments

Comments
 (0)