MCPcopy Create free account
hub / github.com/eggert/tz / delta_nonneg

Function delta_nonneg

zdump.c:714–731  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

712*/
713
714static intmax_t
715delta_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
733static intmax_t
734delta(struct tm *newp, struct tm *oldp)

Callers 1

deltaFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected