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

Function showextrema

zdump.c:830–867  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

828 through HI. LO and HI disagree on definedness. */
829
830static void
831showextrema(timezone_t tz, char *zone, time_t lo, struct tm *lotmp, time_t hi)
832{
833 struct tm localtm[2], gmtm[2];
834 time_t t, boundary = hunt(tz, lo, hi, true);
835 bool old = false;
836 hi = (SECSPERDAY < hi - boundary
837 ? boundary + SECSPERDAY
838 : hi + (hi < TIME_T_MAX));
839 if (SECSPERDAY < boundary - lo) {
840 lo = boundary - SECSPERDAY;
841 lotmp = localtime_rz(tz, &lo, &localtm[old]);
842 }
843 if (lotmp)
844 localtm[old] = *lotmp;
845 else
846 localtm[old].tm_sec = -1;
847 if (! my_gmtime_r(&lo, &gmtm[old]))
848 gmtm[old].tm_sec = -1;
849
850 /* Search sequentially for definedness transitions. Although this
851 could be sped up by refining 'hunt' to search for either
852 localtime or gmtime definedness transitions, it hardly seems
853 worth the trouble. */
854 for (t = lo + 1; t < hi; t++) {
855 bool new = !old;
856 if (! localtime_rz(tz, &t, &localtm[new]))
857 localtm[new].tm_sec = -1;
858 if (! my_gmtime_r(&t, &gmtm[new]))
859 gmtm[new].tm_sec = -1;
860 if (((localtm[old].tm_sec < 0) != (localtm[new].tm_sec < 0))
861 | ((gmtm[old].tm_sec < 0) != (gmtm[new].tm_sec < 0))) {
862 show(tz, zone, t - 1, true);
863 show(tz, zone, t, true);
864 }
865 old = new;
866 }
867}
868
869/* On pre-C99 platforms, a snprintf substitute good enough for us. */
870#if !HAVE_SNPRINTF

Callers 1

mainFunction · 0.85

Calls 4

huntFunction · 0.85
my_gmtime_rFunction · 0.85
showFunction · 0.85
localtime_rzFunction · 0.70

Tested by

no test coverage detected