[34/59] mktime should not consult 'daylight'

Message ID 20250105055750.1668721-35-eggert@cs.ucla.edu (mailing list archive)
State New
Headers
Series time: sync mktime from Gnulib |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Paul Eggert Jan. 5, 2025, 5:57 a.m. UTC
  * 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(-)
  

Patch

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;