about summary refs log tree commit diff
path: root/time/tzset.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-10-25 22:10:12 +0000
committerUlrich Drepper <drepper@redhat.com>1998-10-25 22:10:12 +0000
commit896ebd6bf63941a098a446e9c5f59f92a5507e8d (patch)
tree823f00d9b01d1fef059cc5d036451ec3e94ac148 /time/tzset.c
parenta825f8e844461f21cb891edbdd0e8a22370cd204 (diff)
downloadglibc-896ebd6bf63941a098a446e9c5f59f92a5507e8d.tar.gz
glibc-896ebd6bf63941a098a446e9c5f59f92a5507e8d.tar.xz
glibc-896ebd6bf63941a098a446e9c5f59f92a5507e8d.zip
(tz_compute): If time to switch to DST is later in the year switch back in the next year.
Diffstat (limited to 'time/tzset.c')
-rw-r--r--time/tzset.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/time/tzset.c b/time/tzset.c
index c35017c960..0621cd9af7 100644
--- a/time/tzset.c
+++ b/time/tzset.c
@@ -517,9 +517,20 @@ tz_compute (timer, tm)
      time_t timer;
      const struct tm *tm;
 {
-  if (! compute_change (&tz_rules[0], 1900 + tm->tm_year) ||
-      ! compute_change (&tz_rules[1], 1900 + tm->tm_year))
+  if (! compute_change (&tz_rules[0], 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;
+    }
 
   __daylight = tz_rules[0].offset != tz_rules[1].offset;
   __timezone = -tz_rules[0].offset;