diff options
author | Ulrich Drepper <drepper@redhat.com> | 1999-09-06 17:03:16 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1999-09-06 17:03:16 +0000 |
commit | 7fcc87f4673c79e7dbcc7d972e646383b5e47ce3 (patch) | |
tree | bd6c2115b5d5edf9b8bbcc77737775f31461a444 /time | |
parent | 07c7a0552ab5031edb6af78197b5584a61d055eb (diff) | |
download | glibc-7fcc87f4673c79e7dbcc7d972e646383b5e47ce3.tar.gz |
Update.
1999-09-06 Andreas Schwab <schwab@suse.de>
* time/tzset.c (compute_change): Replace slow loop to compute T by
simple algorithm.
Diffstat (limited to 'time')
-rw-r--r-- | time/tzset.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/time/tzset.c b/time/tzset.c index 24624fa188..6af2fbaf00 100644 --- a/time/tzset.c +++ b/time/tzset.c @@ -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) { |