* time/tzset.c (__tz_compute): Omit last arg USE_LOCALTIME,
since this function should be called only when using localtime.
All callers changed. Clarify isdst computation.
---
time/tzfile.c | 2 +-
time/tzset.c | 35 ++++++++++++-----------------------
time/tzset.h | 2 +-
3 files changed, 14 insertions(+), 25 deletions(-)
@@ -636,7 +636,7 @@ __tzfile_compute (__time64_t timer, int use_localtime,
goto use_last;
/* Use the rules from the TZ string to compute the change. */
- __tz_compute (timer, tp, 1);
+ __tz_compute (timer, tp);
goto leap;
}
@@ -525,32 +525,21 @@ compute_change (tz_rule *rule, int year)
}
-/* Figure out the correct timezone for TM and set `__tzname',
- `__timezone', and `__daylight' accordingly. */
+/* Figure out the correct local timezone for TM. */
void
-__tz_compute (__time64_t timer, struct tm *tm, int use_localtime)
+__tz_compute (__time64_t timer, struct tm *tm)
{
compute_change (&tz_rules[0], 1900 + tm->tm_year);
compute_change (&tz_rules[1], 1900 + tm->tm_year);
- if (use_localtime)
- {
- int isdst;
-
- /* We have to distinguish between northern and southern
- hemisphere. For the latter the daylight saving time
- ends in the next year. */
- if (__builtin_expect (tz_rules[0].change
- > tz_rules[1].change, 0))
- isdst = (timer < tz_rules[1].change
- || timer >= tz_rules[0].change);
- else
- isdst = (timer >= tz_rules[0].change
- && timer < tz_rules[1].change);
- tm->tm_isdst = isdst;
- tm->tm_zone = __tzname[isdst];
- tm->tm_gmtoff = tz_rules[isdst].offset;
- }
+ /* Distinguish between northern and southern hemisphere.
+ For the latter the daylight saving time ends in the next year. */
+ bool isdst = (__glibc_likely (tz_rules[0].change <= tz_rules[1].change)
+ ? tz_rules[0].change <= timer && timer < tz_rules[1].change
+ : ! (tz_rules[1].change <= timer && timer < tz_rules[0].change));
+ tm->tm_isdst = isdst;
+ tm->tm_zone = __tzname[isdst];
+ tm->tm_gmtoff = tz_rules[isdst].offset;
}
/* Reinterpret the TZ environment variable and set `tzname'. */
@@ -599,8 +588,8 @@ __tz_convert (__time64_t timer, int use_localtime, struct tm *tp)
{
if (! __offtime (timer, 0, tp))
tp = NULL;
- else
- __tz_compute (timer, tp, use_localtime);
+ else if (use_localtime)
+ __tz_compute (timer, tp);
leap_correction = 0;
leap_extra_sec = false;
}
@@ -15,7 +15,7 @@ extern void __tzfile_compute (__time64_t timer, int use_localtime,
int *leap_correct, bool *leap_hit,
struct tm *tp) attribute_hidden;
extern void __tzset_parse_tz (const char *tz) attribute_hidden;
-extern void __tz_compute (__time64_t timer, struct tm *tm, int use_localtime)
+extern void __tz_compute (__time64_t timer, struct tm *tm)
__THROW attribute_hidden;
__libc_lock_define (extern, __tzset_lock attribute_hidden);