about summary refs log tree commit diff
path: root/time
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-10-26 09:35:41 +0000
committerUlrich Drepper <drepper@redhat.com>1998-10-26 09:35:41 +0000
commit14f65de69493dee805645c0a782885727d5bdac6 (patch)
treec629ed43765380e84dc07e79168e2f64fd8461d4 /time
parentd499a27c88edd31867935bbf820da405bf4d6534 (diff)
downloadglibc-14f65de69493dee805645c0a782885727d5bdac6.tar.gz
glibc-14f65de69493dee805645c0a782885727d5bdac6.tar.xz
glibc-14f65de69493dee805645c0a782885727d5bdac6.zip
(tz_compute): Correct last patch and describe this in a comment.
Diffstat (limited to 'time')
-rw-r--r--time/tzset.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/time/tzset.c b/time/tzset.c
index 0621cd9af7..6b9f93239b 100644
--- a/time/tzset.c
+++ b/time/tzset.c
@@ -517,20 +517,16 @@ tz_compute (timer, tm)
      time_t timer;
      const struct tm *tm;
 {
-  if (! compute_change (&tz_rules[0], 1900 + tm->tm_year))
+  if (! compute_change (&tz_rules[0], 1900 + tm->tm_year)
+      || ! compute_change (&tz_rules[1], 1900 + tm->tm_year))
     return 0;
   /* We have to distinguish between northern and southern hemisphere.
-     For the later the daylight saving time ends in the next year.  */
-  if (tz_rules[0].change < tz_rules[1].change)
-    {
-      if (! compute_change (&tz_rules[1], 1900 + tm->tm_year))
-	return 0;
-    }
-  else
-    {
-      if (! compute_change (&tz_rules[1], 1900 + tm->tm_year + 1))
-	return 0;
-    }
+     For the later the daylight saving time ends in the next year.
+     It is easier to detect this after first computing the time for the
+     wrong year since now we simply can compare the times to switch.  */
+  if (tz_rules[0].change < tz_rules[1].change
+      && ! compute_change (&tz_rules[1], 1900 + tm->tm_year + 1))
+    return 0;
 
   __daylight = tz_rules[0].offset != tz_rules[1].offset;
   __timezone = -tz_rules[0].offset;