| @@ -1,22 +1,22 @@ | | | @@ -1,22 +1,22 @@ |
1 | /* $NetBSD: zdump.c,v 1.39 2014/10/23 18:45:58 christos Exp $ */ | | 1 | /* $NetBSD: zdump.c,v 1.40 2014/10/23 21:19:53 christos Exp $ */ |
2 | /* | | 2 | /* |
3 | ** This file is in the public domain, so clarified as of | | 3 | ** This file is in the public domain, so clarified as of |
4 | ** 2009-05-17 by Arthur David Olson. | | 4 | ** 2009-05-17 by Arthur David Olson. |
5 | */ | | 5 | */ |
6 | | | 6 | |
7 | #include <sys/cdefs.h> | | 7 | #include <sys/cdefs.h> |
8 | #ifndef lint | | 8 | #ifndef lint |
9 | __RCSID("$NetBSD: zdump.c,v 1.39 2014/10/23 18:45:58 christos Exp $"); | | 9 | __RCSID("$NetBSD: zdump.c,v 1.40 2014/10/23 21:19:53 christos Exp $"); |
10 | #endif /* !defined lint */ | | 10 | #endif /* !defined lint */ |
11 | | | 11 | |
12 | /* | | 12 | /* |
13 | ** This code has been made independent of the rest of the time | | 13 | ** This code has been made independent of the rest of the time |
14 | ** conversion package to increase confidence in the verification it provides. | | 14 | ** conversion package to increase confidence in the verification it provides. |
15 | ** You can use this code to help in verifying other implementations. | | 15 | ** You can use this code to help in verifying other implementations. |
16 | ** | | 16 | ** |
17 | ** To do this, compile with -DUSE_LTZ=0 and link without the tz library. | | 17 | ** To do this, compile with -DUSE_LTZ=0 and link without the tz library. |
18 | */ | | 18 | */ |
19 | | | 19 | |
20 | #ifndef NETBSD_INSPIRED | | 20 | #ifndef NETBSD_INSPIRED |
21 | # define NETBSD_INSPIRED 1 | | 21 | # define NETBSD_INSPIRED 1 |
22 | #endif | | 22 | #endif |
| @@ -850,27 +850,26 @@ delta(struct tm *newp, struct tm *oldp) | | | @@ -850,27 +850,26 @@ delta(struct tm *newp, struct tm *oldp) |
850 | return -delta(oldp, newp); | | 850 | return -delta(oldp, newp); |
851 | result = 0; | | 851 | result = 0; |
852 | for (tmy = oldp->tm_year; tmy < newp->tm_year; ++tmy) | | 852 | for (tmy = oldp->tm_year; tmy < newp->tm_year; ++tmy) |
853 | result += DAYSPERNYEAR + isleap_sum(tmy, TM_YEAR_BASE); | | 853 | result += DAYSPERNYEAR + isleap_sum(tmy, TM_YEAR_BASE); |
854 | result += newp->tm_yday - oldp->tm_yday; | | 854 | result += newp->tm_yday - oldp->tm_yday; |
855 | result *= HOURSPERDAY; | | 855 | result *= HOURSPERDAY; |
856 | result += newp->tm_hour - oldp->tm_hour; | | 856 | result += newp->tm_hour - oldp->tm_hour; |
857 | result *= MINSPERHOUR; | | 857 | result *= MINSPERHOUR; |
858 | result += newp->tm_min - oldp->tm_min; | | 858 | result += newp->tm_min - oldp->tm_min; |
859 | result *= SECSPERMIN; | | 859 | result *= SECSPERMIN; |
860 | result += newp->tm_sec - oldp->tm_sec; | | 860 | result += newp->tm_sec - oldp->tm_sec; |
861 | return result; | | 861 | return result; |
862 | } | | 862 | } |
863 | #endif | | | |
864 | | | 863 | |
865 | #ifndef TM_GMTOFF | | 864 | #ifndef TM_GMTOFF |
866 | /* Return A->tm_yday, adjusted to compare it fairly to B->tm_yday. | | 865 | /* Return A->tm_yday, adjusted to compare it fairly to B->tm_yday. |
867 | Assume A and B differ by at most one year. */ | | 866 | Assume A and B differ by at most one year. */ |
868 | static int | | 867 | static int |
869 | adjusted_yday(struct tm const *a, struct tm const *b) | | 868 | adjusted_yday(struct tm const *a, struct tm const *b) |
870 | { | | 869 | { |
871 | int yday = a->tm_yday; | | 870 | int yday = a->tm_yday; |
872 | if (b->tm_year < a->tm_year) | | 871 | if (b->tm_year < a->tm_year) |
873 | yday += 365 + isleap_sum(b->tm_year, TM_YEAR_BASE); | | 872 | yday += 365 + isleap_sum(b->tm_year, TM_YEAR_BASE); |
874 | return yday; | | 873 | return yday; |
875 | } | | 874 | } |
876 | #endif | | 875 | #endif |