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

Function yeartot

zdump.c:623–664  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

621}
622
623static time_t
624yeartot(intmax_t y)
625{
626 register intmax_t myy, seconds, years;
627 register time_t t;
628
629 myy = EPOCH_YEAR;
630 t = 0;
631 while (myy < y) {
632 if (SECSPER400YEARS_FITS && 400 <= y - myy) {
633 intmax_t diff400 = (y - myy) / 400;
634 if (INTMAX_MAX / SECSPER400YEARS < diff400)
635 return absolute_max_time;
636 seconds = diff400 * SECSPER400YEARS;
637 years = diff400 * 400;
638 } else {
639 seconds = isleap(myy) ? SECSPERLYEAR : SECSPERNYEAR;
640 years = 1;
641 }
642 myy += years;
643 if (t > absolute_max_time - seconds)
644 return absolute_max_time;
645 t += seconds;
646 }
647 while (y < myy) {
648 if (SECSPER400YEARS_FITS && y + 400 <= myy && myy < 0) {
649 intmax_t diff400 = (myy - y) / 400;
650 if (INTMAX_MAX / SECSPER400YEARS < diff400)
651 return absolute_min_time;
652 seconds = diff400 * SECSPER400YEARS;
653 years = diff400 * 400;
654 } else {
655 seconds = isleap(myy - 1) ? SECSPERLYEAR : SECSPERNYEAR;
656 years = 1;
657 }
658 myy -= years;
659 if (t < absolute_min_time + seconds)
660 return absolute_min_time;
661 t -= seconds;
662 }
663 return t;
664}
665
666/* Search for a discontinuity in timezone TZ, in the
667 timestamps ranging from LOT through HIT. LOT and HIT disagree

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected