| 712 | */ |
| 713 | |
| 714 | static intmax_t |
| 715 | delta_nonneg(struct tm *newp, struct tm *oldp) |
| 716 | { |
| 717 | intmax_t oldy = oldp->tm_year; |
| 718 | int cycles = (newp->tm_year - oldy) / YEARSPERREPEAT; |
| 719 | intmax_t sec = SECSPERREPEAT, result = cycles * sec; |
| 720 | int tmy = oldp->tm_year + cycles * YEARSPERREPEAT; |
| 721 | for ( ; tmy < newp->tm_year; ++tmy) |
| 722 | result += DAYSPERNYEAR + isleap_sum(tmy, TM_YEAR_BASE); |
| 723 | result += newp->tm_yday - oldp->tm_yday; |
| 724 | result *= HOURSPERDAY; |
| 725 | result += newp->tm_hour - oldp->tm_hour; |
| 726 | result *= MINSPERHOUR; |
| 727 | result += newp->tm_min - oldp->tm_min; |
| 728 | result *= SECSPERMIN; |
| 729 | result += newp->tm_sec - oldp->tm_sec; |
| 730 | return result; |
| 731 | } |
| 732 | |
| 733 | static intmax_t |
| 734 | delta(struct tm *newp, struct tm *oldp) |