[PATCH 34/59] mktime should not consult 'daylight'
Paul Eggert
eggert@cs.ucla.edu
Sun Jan 5 05:57:09 GMT 2025
* lib/mktime.c (__mktime_internal): Do not consult __daylight as it
has unreliable contents when a geographical timezone is used, and the
user can set it. Instead, use tm_isdst for mktime, and ignore
tm_isdst for timegm. This patch is cherry-picked from Gnulib commit
72abb08f4495bf232736f4d13a24bced72a9c327 dated Thu Nov 14 10:40:24
2024 -0700.
---
time/mktime.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/time/mktime.c b/time/mktime.c
index 3a951b2c8c..0981cd1d1d 100644
--- a/time/mktime.c
+++ b/time/mktime.c
@@ -356,8 +356,8 @@ __mktime_internal (struct tm *tp, bool local, mktime_offset_t *offset)
int mon = tp->tm_mon;
int year_requested = tp->tm_year;
- /* If the timezone never observes DST, ignore any tm_isdst request. */
- int isdst = local && __daylight ? tp->tm_isdst : 0;
+ /* Ignore any tm_isdst request for timegm. */
+ int isdst = local ? tp->tm_isdst : 0;
/* 1 if the previous probe was DST. */
int dst2 = 0;
--
2.45.2
More information about the Libc-alpha
mailing list