]> sourceware.org Git - glibc.git/commitdiff
Update.
authorUlrich Drepper <drepper@redhat.com>
Mon, 6 Sep 1999 17:03:16 +0000 (17:03 +0000)
committerUlrich Drepper <drepper@redhat.com>
Mon, 6 Sep 1999 17:03:16 +0000 (17:03 +0000)
1999-09-06  Andreas Schwab  <schwab@suse.de>

* time/tzset.c (compute_change): Replace slow loop to compute T by
simple algorithm.

ChangeLog
time/tzset.c

index 81a1348614c0cb76131c75a34e11ddfbd5f68f5a..67279cedbb9da37b93bbadc6e1fb33746c75b45b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+1999-09-06  Andreas Schwab  <schwab@suse.de>
+
+       * time/tzset.c (compute_change): Replace slow loop to compute T by
+       simple algorithm.
+
 1999-09-06  Ulrich Drepper  <drepper@cygnus.com>
 
        * iconvdata/iso-2022-jp.c: When translating to ISO-2022-JP* write
index 24624fa188424047952dba8ff421c6eb43fae243..6af2fbaf004770cc17d4186db58c58b71040b083 100644 (file)
@@ -418,16 +418,23 @@ compute_change (rule, year)
      int year;
 {
   register time_t t;
-  int y;
 
   if (year != -1 && rule->computed_for == year)
-    /* Operations on times in 1969 will be slower.  Oh well.  */
+    /* Operations on times in 2 BC will be slower.  Oh well.  */
     return 1;
 
   /* First set T to January 1st, 0:00:00 GMT in YEAR.  */
-  t = 0;
-  for (y = 1970; y < year; ++y)
-    t += SECSPERDAY * (__isleap (y) ? 366 : 365);
+  if (year > 1970)
+    t = ((year - 1970) * 365
+        + /* Compute the number of leapdays between 1970 and YEAR
+             (exclusive).  There is a leapday every 4th year ...  */
+        + ((year - 1) / 4 - 1970 / 4)
+        /* ... except every 100th year ... */
+        - ((year - 1) / 100 - 1970 / 100)
+        /* ... but still every 400th year.  */
+        + ((year - 1) / 400 - 1970 / 400)) * SECSPERDAY;
+  else
+    t = 0;
 
   switch (rule->type)
     {
This page took 0.689727 seconds and 5 git commands to generate.