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

Function limitrange

zic.c:2618–2658  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2616 ptrdiff_t leapbase, leapcount;
2617 bool leapexpiry;
2618};
2619
2620static struct timerange
2621limitrange(struct timerange r, zic_t lo, zic_t hi,
2622 zic_t const *ats, unsigned char const *types)
2623{
2624 /* Omit ordinary transitions < LO. */
2625 while (0 < r.count && ats[r.base] < lo) {
2626 r.defaulttype = types[r.base];
2627 r.count--;
2628 r.base++;
2629 }
2630
2631 /* Omit as many initial leap seconds as possible, such that the
2632 first leap second in the truncated list is <= LO, and is a
2633 positive leap second if and only if it has a positive correction.
2634 This supports common TZif readers that assume that the first leap
2635 second is positive if and only if its correction is positive. */
2636 while (1 < r.leapcount && leap[r.leapbase + 1].trans <= lo) {
2637 r.leapcount--;
2638 r.leapbase++;
2639 }
2640 while (0 < r.leapbase
2641 && ((leap[r.leapbase - 1].corr < leap[r.leapbase].corr)
2642 != (0 < leap[r.leapbase].corr))) {
2643 r.leapcount++;
2644 r.leapbase--;
2645 }
2646
2647
2648 /* Omit ordinary and leap second transitions greater than HI + 1. */
2649 if (hi < max_time) {
2650 while (0 < r.count && hi + 1 < ats[r.base + r.count - 1])
2651 r.count--;
2652 while (0 < r.leapcount && hi + 1 < leap[r.leapbase + r.leapcount - 1].trans)
2653 r.leapcount--;
2654 }
2655
2656 /* Determine whether to append an expiration to the leap second table. */
2657 r.leapexpiry = 0 <= leapexpires && leapexpires - 1 <= hi;
2658
2659 return r;
2660}
2661

Callers 1

writezoneFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected