about summary refs log tree commit diff
path: root/time
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-05-14 19:14:48 +0000
committerUlrich Drepper <drepper@redhat.com>1998-05-14 19:14:48 +0000
commitff152e3fc8c7d38e08d9f9d70eb6109c878e1372 (patch)
tree7fc3fb83b20673816f3f2082ac79558028f02b25 /time
parent847a35a07b6412a24f8978cf2a7fafc4e5c4a471 (diff)
downloadglibc-ff152e3fc8c7d38e08d9f9d70eb6109c878e1372.tar.gz
glibc-ff152e3fc8c7d38e08d9f9d70eb6109c878e1372.tar.xz
glibc-ff152e3fc8c7d38e08d9f9d70eb6109c878e1372.zip
Update.
1998-05-14 13:25  Ulrich Drepper  <drepper@cygnus.com>

	* inet/netinet/in.h: Add defines for multicast.
	Reported by Jeremy Hall <jhall@UU.NET>.

	* stdlib/stdlib.h: Add prototypes for __setenv and __unsetenv.
	* sysdeps/generic/putenv.c: Use __setenv and __unsetenv, not setenv
	and unsetenv.  Optimize _LIBC case.
	* sysdeps/generic/setenv.c: Prevent unnecessary memory leaks.
	Define functions with leading __.

	* time/tzfile.c: Correct handling of global variables daylight,
	timezone, and tzname.
	* time/tzset.c: Likewise.
	* timezone/Makefile (tests): Add tst-timezone.
	* timezone/tst-timezone.c: New file.

1998-05-14 10:35  Ulrich Drepper  <drepper@cygnus.com>

	* timezone/asia: Update from tzdata1998d.
	* timezone/australasia: Likewise.
	* timezone/europe: Likewise.
Diffstat (limited to 'time')
-rw-r--r--time/tzfile.c51
-rw-r--r--time/tzset.c12
2 files changed, 35 insertions, 28 deletions
diff --git a/time/tzfile.c b/time/tzfile.c
index 7dcf88dbe9..c9becf3238 100644
--- a/time/tzfile.c
+++ b/time/tzfile.c
@@ -54,6 +54,8 @@ static unsigned char *type_idxs = NULL;
 static size_t num_types;
 static struct ttinfo *types = NULL;
 static char *zone_names = NULL;
+static long int rule_stdoff;
+static long int rule_dstoff;
 static size_t num_leaps;
 static struct leap *leaps = NULL;
 
@@ -266,15 +268,32 @@ __tzfile_read (const char *file)
 
   fclose (f);
 
-  info = find_transition (0);
+  /* Find the standard and daylight time offsets used by the rule file.
+     We choose the offsets in the types of each flavor that are
+     transitioned to earliest in time.  */
+  __tzname[1] = NULL;
   for (i = 0; i < num_types && i < sizeof (__tzname) / sizeof (__tzname[0]);
        ++i)
     __tzname[types[i].isdst] = __tzstring (&zone_names[types[i].idx]);
-  if (info->isdst < sizeof (__tzname) / sizeof (__tzname[0]))
-    __tzname[info->isdst] = __tzstring (&zone_names[info->idx]);
+  if (__tzname[1] == NULL)
+    __tzname[1] = __tzname[0];
 
   compute_tzname_max (chars);
 
+  rule_stdoff = rule_dstoff = 0;
+  for (i = 0; i < num_transitions; ++i)
+    {
+      if (!rule_stdoff && !types[type_idxs[i]].isdst)
+	rule_stdoff = types[type_idxs[i]].offset;
+      if (!rule_dstoff && types[type_idxs[i]].isdst)
+	rule_dstoff = types[type_idxs[i]].offset;
+      if (rule_stdoff && rule_dstoff)
+	break;
+    }
+
+  __daylight = rule_stdoff != rule_dstoff;
+  __timezone = -rule_stdoff;
+
   __use_tzfile = 1;
   return;
 
@@ -291,7 +310,6 @@ __tzfile_default (const char *std, const char *dst,
 		  long int stdoff, long int dstoff)
 {
   size_t stdlen, dstlen, i;
-  long int rule_offset, rule_stdoff, rule_dstoff;
   int isdst;
 
   __tzfile_read (TZDEFRULES);
@@ -318,24 +336,9 @@ __tzfile_default (const char *std, const char *dst,
     }
   __mempcpy (__mempcpy (zone_names, std, stdlen), dst, dstlen);
 
-  /* Find the standard and daylight time offsets used by the rule file.
-     We choose the offsets in the types of each flavor that are
-     transitioned to earliest in time.  */
-  rule_stdoff = rule_dstoff = 0;
-  for (i = 0; i < num_transitions; ++i)
-    {
-      if (!rule_stdoff && !types[type_idxs[i]].isdst)
-	rule_stdoff = types[type_idxs[i]].offset;
-      if (!rule_dstoff && types[type_idxs[i]].isdst)
-	rule_dstoff = types[type_idxs[i]].offset;
-      if (rule_stdoff && rule_dstoff)
-	break;
-    }
-
   /* Now correct the transition times for the user-specified standard and
      daylight offsets from GMT.  */
   isdst = 0;
-  rule_offset = rule_offset;
   for (i = 0; i < num_transitions; ++i)
     {
       struct ttinfo *trans_type = &types[type_idxs[i]];
@@ -419,14 +422,16 @@ __tzfile_compute (time_t timer, int use_localtime,
   if (use_localtime)
     {
       struct ttinfo *info = find_transition (timer);
-      __daylight = info->isdst;
-      __timezone = -info->offset;
+      __daylight = rule_stdoff != rule_dstoff;
+      __timezone = -rule_stdoff;
+      __tzname[1] = NULL;
       for (i = 0;
 	   i < num_types && i < sizeof (__tzname) / sizeof (__tzname[0]);
 	   ++i)
 	__tzname[types[i].isdst] = &zone_names[types[i].idx];
-      if (info->isdst < sizeof (__tzname) / sizeof (__tzname[0]))
-	__tzname[info->isdst] = &zone_names[info->idx];
+      if (__tzname[1] == NULL)
+	/* There is no daylight saving time.  */
+	__tzname[1] = __tzname[0];
     }
 
   *leap_correct = 0L;
diff --git a/time/tzset.c b/time/tzset.c
index e766796513..e42be39db8 100644
--- a/time/tzset.c
+++ b/time/tzset.c
@@ -333,6 +333,7 @@ tzset_internal (always)
     {
       /* There is no DST.  */
       tz_rules[1].name = tz_rules[0].name;
+      tz_rules[1].offset = tz_rules[0].offset;
       free (tzbuf);
       return;
     }
@@ -547,8 +548,8 @@ tz_compute (timer, tm)
       ! compute_change (&tz_rules[1], 1900 + tm->tm_year))
     return 0;
 
-  __daylight = timer >= tz_rules[0].change && timer < tz_rules[1].change;
-  __timezone = -tz_rules[__daylight].offset;
+  __daylight = tz_rules[0].offset != tz_rules[1].offset;
+  __timezone = -tz_rules[0].offset;
   __tzname[0] = (char *) tz_rules[0].name;
   __tzname[1] = (char *) tz_rules[1].name;
 
@@ -626,9 +627,10 @@ __tz_convert (const time_t *timer, int use_localtime, struct tm *tp)
     {
       if (use_localtime)
 	{
-	  tp->tm_isdst = __daylight;
-	  tp->tm_zone = __tzname[__daylight];
-	  tp->tm_gmtoff = -__timezone;
+	  tp->tm_isdst = (*timer >= tz_rules[0].change
+			  && *timer < tz_rules[1].change);
+	  tp->tm_zone = __tzname[tp->tm_isdst];
+	  tp->tm_gmtoff = tz_rules[tp->tm_isdst].offset;
 	}
       else
 	{