Skip to content

Commit b665d10

Browse files
committed
WIP - add "naive" fix for C implementation
1 parent d3b6683 commit b665d10

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

Modules/_datetimemodule.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6153,17 +6153,31 @@ local_to_seconds(int year, int month, int day,
61536153
static PyObject *
61546154
local_timezone_from_local(PyDateTime_DateTime *local_dt)
61556155
{
6156-
long long seconds;
6156+
long long seconds, seconds2;
61576157
time_t timestamp;
6158+
int fold = DATE_GET_FOLD(local_dt);
61586159
seconds = local_to_seconds(GET_YEAR(local_dt),
61596160
GET_MONTH(local_dt),
61606161
GET_DAY(local_dt),
61616162
DATE_GET_HOUR(local_dt),
61626163
DATE_GET_MINUTE(local_dt),
61636164
DATE_GET_SECOND(local_dt),
6164-
DATE_GET_FOLD(local_dt));
6165+
fold);
61656166
if (seconds == -1)
61666167
return NULL;
6168+
seconds2 = local_to_seconds(GET_YEAR(local_dt),
6169+
GET_MONTH(local_dt),
6170+
GET_DAY(local_dt),
6171+
DATE_GET_HOUR(local_dt),
6172+
DATE_GET_MINUTE(local_dt),
6173+
DATE_GET_SECOND(local_dt),
6174+
!fold);
6175+
if (seconds2 == -1)
6176+
return NULL;
6177+
/* Detect gap */
6178+
if (seconds2 != seconds && (seconds2 > seconds) == fold)
6179+
seconds = seconds2;
6180+
61676181
/* XXX: add bounds check */
61686182
timestamp = seconds - epoch;
61696183
return local_timezone_from_timestamp(timestamp);

0 commit comments

Comments
 (0)