@@ -8190,17 +8190,16 @@ The value of C<isdst> is used as follows:
81908190
81918191=item 0
81928192
8193- No daylight savings time is in effect
8193+ The caller knows that daylight savings time is not in effect
81948194
81958195=item E<gt>0
81968196
8197- Check if daylight savings time is in effect, and adjust the results
8198- accordingly .
8197+ The caller knows that daylight savings time is in effect, though the
8198+ underlying libc function may choose to override this .
81998199
82008200=item E<lt>0
82018201
8202- This value is reserved for internal use by the L<POSIX> module for backwards
8203- compatibility purposes.
8202+ The function is to calculate itself if daylight savings time is in effect.
82048203
82058204=back
82068205
@@ -8269,15 +8268,8 @@ Perl_sv_strftime_ints(pTHX_ SV * fmt, int sec, int min, int hour,
82698268 const char * locale = "C" ;
82708269#endif
82718270
8272- /* A negative 'isdst' triggers backwards compatibility mode for
8273- * POSIX::strftime(), in which 0 is always passed to ints_to_tm() so that
8274- * the possibility of daylight savings time is never considered, But, a 1
8275- * is eventually passed to libc strftime() so that it returns the results
8276- * it always has for a non-zero 'isdst'. See GH #22351 */
82778271 struct tm mytm ;
8278- ints_to_tm (& mytm , locale , sec , min , hour , mday , mon , year ,
8279- MAX (0 , isdst ));
8280- mytm .tm_isdst = MIN (1 , abs (isdst ));
8272+ ints_to_tm (& mytm , locale , sec , min , hour , mday , mon , year , isdst );
82818273 return sv_strftime_common (fmt , locale , & mytm );
82828274}
82838275
@@ -8372,9 +8364,6 @@ S_ints_to_tm(pTHX_ struct tm * mytm,
83728364 /* On platforms that have either of these two fields, we have to run the
83738365 * libc mktime() in order to set them, as mini_mktime() doesn't deal with
83748366 * them. [perl #18238] */
8375- # if defined(HAS_TM_TM_GMTOFF ) || defined(HAS_TM_TM_ZONE )
8376- # define ALWAYS_RUN_MKTIME
8377- # endif
83788367
83798368 /* When isdst is 0, it means to consider daylight savings time as never
83808369 * being in effect. Many libc implementations of mktime() do not allow
@@ -8383,30 +8372,33 @@ S_ints_to_tm(pTHX_ struct tm * mytm,
83838372 if (isdst == 0 ) {
83848373 mini_mktime (mytm );
83858374
8386- # ifndef ALWAYS_RUN_MKTIME
8387-
8388- /* When we don't always need libc mktime(), we call it only when we didn't
8389- * call mini_mktime() */
8390- } else {
8375+ # if defined(HAS_TM_TM_GMTOFF ) || defined(HAS_TM_TM_ZONE )
83918376
8392- # else
83938377 /* Here will have to run libc mktime() in order to get the values of
83948378 * some fields that mini_mktime doesn't populate. We don't want
8395- * mktime's side effect of looking for dst, so we have to have a
8396- * separate tm structure from which we copy just those fields into the
8397- * returned structure. Initialize its values. mytm should now be a
8398- * normalized version of the input . */
8379+ * mktime's side effect of looking for dst (because isdst==0) , so we
8380+ * have to have a separate tm structure from which we copy just those
8381+ * fields into the structure we return . Initialize its values, which
8382+ * have now been normalized by mini_mktime . */
83998383 aux_tm = * mytm ;
8400- aux_tm .tm_isdst = isdst ;
84018384 which_tm = & aux_tm ;
8385+ }
8386+
8387+ # else
8388+
8389+ }
8390+ else /* Don't run libc mktime if both: we ran mini_mktime above, and we
8391+ don't have to always run libc mktime */
84028392
84038393# endif
84048394
8395+ {
84058396 /* Here, we need to run libc mktime(), either because we want to take
84068397 * dst into consideration, or because it calculates one or two fields
8407- * that we need that mini_mktime() doesn't handle.
8408- *
8409- * Unlike mini_mktime(), it does consider the locale, so have to switch
8398+ * that we need that mini_mktime() doesn't handle. */
8399+ which_tm -> tm_isdst = isdst ;
8400+
8401+ /* Unlike mini_mktime(), it does consider the locale, so have to switch
84108402 * to the correct one. */
84118403 const char * orig_TIME_locale = toggle_locale_c (LC_TIME , locale );
84128404 MKTIME_LOCK ;
@@ -8436,7 +8428,6 @@ S_ints_to_tm(pTHX_ struct tm * mytm,
84368428 }
84378429
84388430# endif
8439- # undef ALWAYS_RUN_MKTIME
84408431#endif
84418432
84428433 return ;
0 commit comments