Lines Matching +full:offset +full:- +full:y
5 ** 1996-06-05 by Arthur David Olson.
10 ** POSIX.1-1988 style TZ environment variable handling from Guy Harris.
28 #include "un-namespace.h"
53 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 :+-._"
61 ** Support non-POSIX platforms that distinguish between text and binary files.
94 static char const *utc = etc_utc + sizeof "Etc/" - 1;
98 ** Default to US rules as of 2017-05-07.
107 int_fast32_t tt_utoff; /* UT offset in seconds */
120 static char const UNSPEC[] = "-00";
126 enum { CHARS_EXTRA = max(sizeof UNSPEC, 2) - 1 };
209 ** Section 4.12.3 of X3.159-1989 requires that
212 ** objects: a broken-down time structure and an array of char.
242 s->tt_utoff = utoff;
243 s->tt_isdst = isdst;
244 s->tt_desigidx = desigidx;
245 s->tt_ttisstd = false;
246 s->tt_ttisut = false;
253 char const *abbr = &sp->chars[sp->ttis[i].tt_desigidx];
264 int_fast32_t halfmaxval = one << (32 - 2);
265 int_fast32_t maxval = halfmaxval - 1 + halfmaxval;
266 int_fast32_t minval = -1 - maxval;
273 /* Do two's-complement negation even on non-two's-complement machines.
274 If the result would be minval - 1, return minval. */
275 result -= !TWOS_COMPLEMENT(int_fast32_t) && result != 0;
287 int_fast64_t halfmaxval = one << (64 - 2);
288 int_fast64_t maxval = halfmaxval - 1 + halfmaxval;
289 int_fast64_t minval = -TWOS_COMPLEMENT(int_fast64_t) - maxval;
296 /* Do two's-complement negation even on non-two's-complement machines.
297 If the result would be minval - 1, return minval. */
298 result -= !TWOS_COMPLEMENT(int_fast64_t) && result != 0;
308 tzname[ttisp->tt_isdst] = (char *) &sp->chars[ttisp->tt_desigidx];
311 if (!ttisp->tt_isdst)
312 timezone = - ttisp->tt_utoff;
315 if (ttisp->tt_isdst)
316 altzone = - ttisp->tt_utoff;
327 struct ttinfo *ttisp = &sp->ttis[type];
328 int this_bit = 1 << ttisp->tt_isdst;
364 for (i = sp->timecnt - 1; stddst_mask && 0 <= i; i--)
365 stddst_mask = may_update_tzname_etc(stddst_mask, sp, sp->types[i]);
366 for (i = sp->typecnt - 1; stddst_mask && 0 <= i; i--)
383 for (i = 0; i < sp->charcnt - (TZNAME_MAXIMUM + 1); ) {
384 int len = strlen(&sp->chars[i]);
391 for (i = 0; i < sp->charcnt; ++i)
392 if (strchr(TZ_ABBR_CHAR_SET, sp->chars[i]) == NULL)
393 sp->chars[i] = TZ_ABBR_ERR_CHAR;
401 * Returns: -1 on error
415 return -1;
482 register union input_buffer *up = &lsp->u.u;
485 sp->goback = sp->goahead = false;
496 if (sizeof lsp->fullname - sizeof tzdirslash <= strlen(name))
502 memcpy(lsp->fullname, tzdirslash, sizeof tzdirslash);
503 strcpy(lsp->fullname + sizeof tzdirslash, name);
505 name = lsp->fullname;
526 nread = _read(fid, up->buf, sizeof up->buf);
535 char version = up->tzhead.tzh_version[0];
538 int_fast32_t ttisstdcnt = detzcode(up->tzhead.tzh_ttisstdcnt);
539 int_fast32_t ttisutcnt = detzcode(up->tzhead.tzh_ttisutcnt);
540 int_fast64_t prevtr = -1;
542 int_fast32_t leapcnt = detzcode(up->tzhead.tzh_leapcnt);
543 int_fast32_t timecnt = detzcode(up->tzhead.tzh_timecnt);
544 int_fast32_t typecnt = detzcode(up->tzhead.tzh_typecnt);
545 int_fast32_t charcnt = detzcode(up->tzhead.tzh_charcnt);
546 char const *p = up->buf + tzheadsize;
574 sp->leapcnt = leapcnt;
575 sp->timecnt = timecnt;
576 sp->typecnt = typecnt;
577 sp->charcnt = charcnt;
583 for (i = 0; i < sp->timecnt; ++i) {
586 sp->types[i] = at <= TIME_T_MAX;
587 if (sp->types[i]) {
591 if (timecnt && attime <= sp->ats[timecnt - 1]) {
592 if (attime < sp->ats[timecnt - 1])
594 sp->types[i - 1] = 0;
595 timecnt--;
597 sp->ats[timecnt++] = attime;
603 for (i = 0; i < sp->timecnt; ++i) {
605 if (sp->typecnt <= typ)
607 if (sp->types[i])
608 sp->types[timecnt++] = typ;
610 sp->timecnt = timecnt;
611 for (i = 0; i < sp->typecnt; ++i) {
615 ttisp = &sp->ttis[i];
616 ttisp->tt_utoff = detzcode(p);
621 ttisp->tt_isdst = isdst;
623 if (! (desigidx < sp->charcnt))
625 ttisp->tt_desigidx = desigidx;
627 for (i = 0; i < sp->charcnt; ++i)
628 sp->chars[i] = *p++;
629 /* Ensure '\0'-terminated, and make it safe to call
631 memset(&sp->chars[i], 0, CHARS_EXTRA);
635 for (i = 0; i < sp->leapcnt; ++i) {
654 || corr == prevcorr - 1))))
660 sp->lsis[leapcnt].ls_trans = tr;
661 sp->lsis[leapcnt].ls_corr = corr;
665 sp->leapcnt = leapcnt;
667 for (i = 0; i < sp->typecnt; ++i) {
670 ttisp = &sp->ttis[i];
672 ttisp->tt_ttisstd = false;
676 ttisp->tt_ttisstd = *p++;
679 for (i = 0; i < sp->typecnt; ++i) {
682 ttisp = &sp->ttis[i];
684 ttisp->tt_ttisut = false;
688 ttisp->tt_ttisut = *p++;
693 nread -= p - up->buf;
694 memmove(up->buf, p, nread);
701 up->buf[0] == '\n' && up->buf[nread - 1] == '\n' &&
702 sp->typecnt + 2 <= TZ_MAX_TYPES) {
703 struct state *ts = &lsp->u.st;
705 up->buf[nread - 1] = '\0';
706 if (tzparse(&up->buf[1], ts, sp)) {
711 sp->charcnt equals 40 (for LMT AST AWT APT AHST
712 AHDT YST AKDT AKST) and ts->charcnt equals 10
713 (for AKST AKDT). Reusing means sp->charcnt can
716 int charcnt = sp->charcnt;
717 for (i = 0; i < ts->typecnt; i++) {
718 char *tsabbr = ts->chars + ts->ttis[i].tt_desigidx;
721 if (strcmp(sp->chars + j, tsabbr) == 0) {
722 ts->ttis[i].tt_desigidx = j;
729 strcpy(sp->chars + j, tsabbr);
731 ts->ttis[i].tt_desigidx = j;
736 if (gotabbr == ts->typecnt) {
737 sp->charcnt = charcnt;
739 /* Ignore any trailing, no-op transitions generated
742 while (1 < sp->timecnt
743 && (sp->types[sp->timecnt - 1]
744 == sp->types[sp->timecnt - 2]))
745 sp->timecnt--;
747 sp->goahead = ts->goahead;
749 for (i = 0; i < ts->timecnt; i++) {
750 time_t t = ts->ats[i];
752 || (0 < sp->timecnt
753 && t <= sp->ats[sp->timecnt - 1]))
755 if (TZ_MAX_TIMES <= sp->timecnt) {
756 sp->goahead = false;
759 sp->ats[sp->timecnt] = t;
760 sp->types[sp->timecnt] = (sp->typecnt
761 + ts->types[i]);
762 sp->timecnt++;
764 for (i = 0; i < ts->typecnt; i++)
765 sp->ttis[sp->typecnt++] = ts->ttis[i];
769 if (sp->typecnt == 0)
822 while ((c = *strp) != '\0' && !is_digit(c) && c != ',' && c != '-' &&
835 ** We don't do any checking here; checking is done later in common-case code.
865 num = num * 10 + (c - '0');
891 ** 'HOURSPERDAY * DAYSPERWEEK - 1' allows quasi-POSIX rules like
896 strp = getnum(strp, &num, 0, HOURSPERDAY * DAYSPERWEEK - 1);
902 strp = getnum(strp, &num, 0, MINSPERHOUR - 1);
919 ** Given a pointer into a timezone string, extract an offset, in
920 ** [+-]hh[:mm[:ss]] form, from the string.
930 if (*strp == '-') {
939 *offsetp = -*offsetp;
958 rulep->r_type = JULIAN_DAY;
960 strp = getnum(strp, &rulep->r_day, 1, DAYSPERNYEAR);
965 rulep->r_type = MONTH_NTH_DAY_OF_WEEK;
967 strp = getnum(strp, &rulep->r_mon, 1, MONSPERYEAR);
972 strp = getnum(strp, &rulep->r_week, 1, 5);
977 strp = getnum(strp, &rulep->r_day, 0, DAYSPERWEEK - 1);
982 rulep->r_type = DAY_OF_YEAR;
983 strp = getnum(strp, &rulep->r_day, 0, DAYSPERLYEAR - 1);
992 strp = getoffset(strp, &rulep->r_time);
993 } else rulep->r_time = 2 * SECSPERHOUR; /* default = 2:00:00 */
998 ** Given a year, a rule, and the offset from UT at the time that rule takes
999 ** effect, calculate the year-relative time that rule takes effect.
1004 const int_fast32_t offset)
1012 switch (rulep->r_type) {
1016 ** Jn - Julian day, 1 == January 1, 60 == March 1 even in leap
1018 ** In non-leap years, or if the day number is 59 or less, just
1019 ** add SECSPERDAY times the day number-1 to the time of
1022 value = (rulep->r_day - 1) * SECSPERDAY;
1023 if (leapyear && rulep->r_day >= 60)
1029 ** n - day of year.
1033 value = rulep->r_day * SECSPERDAY;
1038 ** Mm.n.d - nth "dth day" of month m.
1042 ** Use Zeller's Congruence to get day-of-week of first day of
1045 m1 = (rulep->r_mon + 9) % 12 + 1;
1046 yy0 = (rulep->r_mon <= 2) ? (year - 1) : year;
1049 dow = ((26 * m1 - 2) / 10 +
1050 1 + yy2 + yy2 / 4 + yy1 / 4 - 2 * yy1) % 7;
1055 ** "dow" is the day-of-week of the first day of the month. Get
1056 ** the day-of-month (zero-origin) of the first "dow" day of the
1059 d = rulep->r_day - dow;
1062 for (i = 1; i < rulep->r_week; ++i) {
1064 mon_lengths[leapyear][rulep->r_mon - 1])
1070 ** "d" is the day-of-month (zero-origin) of the day we want.
1073 for (i = 0; i < rulep->r_mon - 1; ++i)
1081 ** "value" is the year-relative time of 00:00:00 UT on the day in
1082 ** question. To get the year-relative time of the specified local
1083 ** time on that day, add the transition time and the current offset
1086 return value + rulep->r_time + offset;
1113 stdlen = name - stdname;
1117 stdlen = name - stdname;
1126 if (0 < basep->timecnt)
1127 atlo = basep->ats[basep->timecnt - 1];
1129 sp->leapcnt = basep->leapcnt;
1130 memcpy(sp->lsis, basep->lsis, sp->leapcnt * sizeof *sp->lsis);
1134 sp->leapcnt = 0; /* So, we're off a little. */
1136 if (0 < sp->leapcnt)
1137 leaplo = sp->lsis[sp->leapcnt - 1].ls_trans;
1138 sp->goback = sp->goahead = false;
1145 dstlen = name - dstname;
1150 dstlen = name - dstname; /* length of DST abbr. */
1159 } else dstoffset = stdoffset - SECSPERHOUR;
1180 sp->typecnt = 2; /* standard time and DST */
1184 init_ttinfo(&sp->ttis[0], -stdoffset, false, 0);
1185 init_ttinfo(&sp->ttis[1], -dstoffset, true, stdlen + 1);
1192 = year_lengths[isleap(yearbeg - 1)] * SECSPERDAY;
1194 yearbeg--;
1195 if (increment_overflow_time(&janfirst1, -yearsecs)) {
1196 janoffset = -yearsecs;
1201 && EPOCH_YEAR - YEARSPERREPEAT / 2 < yearbeg);
1234 && endtime - starttime < yearsecs)) {
1235 if (TZ_MAX_TIMES - 2 < timecnt)
1237 sp->ats[timecnt] = janfirst;
1239 (&sp->ats[timecnt],
1241 && atlo <= sp->ats[timecnt])
1242 sp->types[timecnt++] = !reversed;
1243 sp->ats[timecnt] = janfirst;
1245 (&sp->ats[timecnt],
1247 && atlo <= sp->ats[timecnt]) {
1248 sp->types[timecnt++] = reversed;
1262 sp->timecnt = timecnt;
1264 sp->ttis[0] = sp->ttis[1];
1265 sp->typecnt = 1; /* Perpetual DST. */
1266 } else if (years_of_observations <= year - yearbeg)
1267 sp->goback = sp->goahead = true;
1282 for (i = 0; i < sp->timecnt; ++i) {
1283 j = sp->types[i];
1284 if (!sp->ttis[j].tt_isdst) {
1286 - sp->ttis[j].tt_utoff;
1291 for (i = 0; i < sp->timecnt; ++i) {
1292 j = sp->types[i];
1293 if (sp->ttis[j].tt_isdst) {
1295 - sp->ttis[j].tt_utoff;
1307 for (i = 0; i < sp->timecnt; ++i) {
1308 j = sp->types[i];
1309 sp->types[i] = sp->ttis[j].tt_isdst;
1310 if (sp->ttis[j].tt_ttisut) {
1317 ** the daylight saving time offset to
1319 ** the standard time offset to the
1326 ** DST offset.
1328 if (isdst && !sp->ttis[j].tt_ttisstd) {
1329 sp->ats[i] += dstoffset -
1332 sp->ats[i] += stdoffset -
1336 theiroffset = -sp->ttis[j].tt_utoff;
1337 if (sp->ttis[j].tt_isdst)
1344 init_ttinfo(&sp->ttis[0], -stdoffset, false, 0);
1345 init_ttinfo(&sp->ttis[1], -dstoffset, true, stdlen + 1);
1346 sp->typecnt = 2;
1350 sp->typecnt = 1; /* only standard time */
1351 sp->timecnt = 0;
1352 init_ttinfo(&sp->ttis[0], -stdoffset, false, 0);
1354 sp->charcnt = charcnt;
1355 cp = sp->chars;
1392 if ((current_time - last_checked > DETECT_TZ_CHANGES_INTERVAL) ||
1413 sp->leapcnt = 0; /* so, we're off a little */
1414 sp->timecnt = 0;
1415 sp->typecnt = 0;
1416 sp->charcnt = 0;
1417 sp->goback = sp->goahead = false;
1418 init_ttinfo(&sp->ttis[0], 0, false, 0);
1419 strcpy(sp->chars, utc);
1435 int lcl = name ? strlen(name) < sizeof lcl_TZname : -1;
1525 ** POSIX.1-2024 removes ctime_r. Both have potential security problems that
1563 if ((sp->goback && t < sp->ats[0]) ||
1564 (sp->goahead && t > sp->ats[sp->timecnt - 1])) {
1569 if (t < sp->ats[0])
1570 seconds = sp->ats[0] - t;
1571 else seconds = t - sp->ats[sp->timecnt - 1];
1572 --seconds;
1579 if (t < sp->ats[0])
1582 newt = t - seconds - SECSPERREPEAT;
1584 if (newt < sp->ats[0] ||
1585 newt > sp->ats[sp->timecnt - 1])
1590 if (t < sp->ats[0]
1591 ? ckd_sub(&result->tm_year,
1592 result->tm_year, years)
1593 : ckd_add(&result->tm_year,
1594 result->tm_year, years))
1599 newy = result->tm_year;
1600 if (t < sp->ats[0])
1601 newy -= years;
1605 result->tm_year = newy;
1610 if (sp->timecnt == 0 || t < sp->ats[0]) {
1614 register int hi = sp->timecnt;
1619 if (t < sp->ats[mid])
1623 i = sp->types[lo - 1];
1625 ttisp = &sp->ttis[i];
1629 ** t += ttisp->tt_utoff;
1632 result = timesub(&t, ttisp->tt_utoff, sp, tmp);
1634 result->tm_isdst = ttisp->tt_isdst;
1636 result->TM_ZONE = (char *) &sp->chars[ttisp->tt_desigidx];
1718 int_fast32_t offset, struct tm *tmp)
1722 result = timesub(timep, offset, gmtptr, tmp);
1726 ** "+xx" or "-xx" if offset is non-zero,
1729 tmp->TM_ZONE = ((char *)
1730 (offset ? wildabbr : gmtptr ? gmtptr->chars : utc));
1736 * Re-entrant version of gmtime.
1783 Callers can instead use localtime_rz with a fixed-offset zone. */
1786 offtime_r(time_t const *restrict timep, long offset, struct tm *restrict tmp)
1789 return gmtsub(gmtptr, timep, offset, tmp);
1800 offtime(const time_t *timep, long offset)
1823 return offtime_r(timep, offset, p_tm);
1834 leaps_thru_end_of_nonneg(time_t y)
1836 return y / 4 - y / 100 + y / 400;
1840 leaps_thru_end_of(time_t y)
1842 return (y < 0
1843 ? -1 - leaps_thru_end_of_nonneg(-1 - y)
1844 : leaps_thru_end_of_nonneg(y));
1848 timesub(const time_t *timep, int_fast32_t offset,
1857 time_t y;
1865 i = (sp == NULL) ? 0 : sp->leapcnt;
1866 while (--i >= 0) {
1867 lp = &sp->lsis[i];
1868 if (*timep >= lp->ls_trans) {
1869 corr = lp->ls_corr;
1870 if ((i == 0 ? 0 : lp[-1].ls_corr) < corr)
1871 secs_since_posleap = *timep - lp->ls_trans;
1880 rem += offset % SECSPERDAY - corr % SECSPERDAY + 3 * SECSPERDAY;
1881 dayoff = offset / SECSPERDAY - corr / SECSPERDAY + rem / SECSPERDAY - 3;
1883 /* y = (EPOCH_YEAR
1885 sans overflow. But calculate against 1570 (EPOCH_YEAR -
1890 y = (EPOCH_YEAR - YEARSPERREPEAT
1892 - ((dayrem % DAYSPERREPEAT) < 0)
1899 /* Increase Y and decrease IDAYS until IDAYS is in range for Y. */
1900 while (year_lengths[isleap(y)] <= idays) {
1903 time_t newy = y + ydelta;
1905 leapdays = leaps_thru_end_of(newy - 1) -
1906 leaps_thru_end_of(y - 1);
1907 idays -= ydelta * DAYSPERNYEAR;
1908 idays -= leapdays;
1909 y = newy;
1913 if (ckd_add(&tmp->tm_year, y, -TM_YEAR_BASE)) {
1918 if (!TYPE_SIGNED(time_t) && y < TM_YEAR_BASE) {
1919 int signed_y = y;
1920 tmp->tm_year = signed_y - TM_YEAR_BASE;
1921 } else if ((!TYPE_SIGNED(time_t) || INT_MIN + TM_YEAR_BASE <= y)
1922 && y - TM_YEAR_BASE <= INT_MAX)
1923 tmp->tm_year = y - TM_YEAR_BASE;
1929 tmp->tm_yday = idays;
1933 tmp->tm_wday = (TM_WDAY_BASE
1934 + ((tmp->tm_year % DAYSPERWEEK)
1936 + leaps_thru_end_of(y - 1)
1937 - leaps_thru_end_of(TM_YEAR_BASE - 1)
1939 tmp->tm_wday %= DAYSPERWEEK;
1940 if (tmp->tm_wday < 0)
1941 tmp->tm_wday += DAYSPERWEEK;
1942 tmp->tm_hour = rem / SECSPERHOUR;
1944 tmp->tm_min = rem / SECSPERMIN;
1945 tmp->tm_sec = rem % SECSPERMIN;
1949 tmp->tm_sec += secs_since_posleap <= tmp->tm_sec;
1951 ip = mon_lengths[isleap(y)];
1952 for (tmp->tm_mon = 0; idays >= ip[tmp->tm_mon]; ++(tmp->tm_mon))
1953 idays -= ip[tmp->tm_mon];
1954 tmp->tm_mday = idays + 1;
1955 tmp->tm_isdst = 0;
1957 tmp->TM_GMTOFF = offset;
1972 # define WRONG (-1)
1989 ** or if j > INT_MAX - i; given i >= 0, INT_MAX - i cannot overflow.
1991 ** or if j < INT_MIN - i; given i < 0, INT_MIN - i cannot overflow.
1993 if ((i >= 0) ? (j > INT_MAX - i) : (j < INT_MIN - i))
2008 if ((l >= 0) ? (m > INT_FAST32_MAX - l) : (m < INT_FAST32_MIN - l))
2027 ? (TYPE_SIGNED(time_t) ? TIME_T_MIN - j <= *tp : -1 - j < *tp)
2028 : *tp <= TIME_T_MAX - j))
2042 (-1 - (-1 - *unitsptr) / base);
2043 *unitsptr -= tensdelta * base;
2054 (-1 - (-1 - *unitsptr) / base);
2055 *unitsptr -= tensdelta * base;
2065 if (atmp->tm_year != btmp->tm_year)
2066 return atmp->tm_year < btmp->tm_year ? -1 : 1;
2067 if ((result = (atmp->tm_mon - btmp->tm_mon)) == 0 &&
2068 (result = (atmp->tm_mday - btmp->tm_mday)) == 0 &&
2069 (result = (atmp->tm_hour - btmp->tm_hour)) == 0 &&
2070 (result = (atmp->tm_min - btmp->tm_min)) == 0)
2071 result = atmp->tm_sec - btmp->tm_sec;
2080 dest->tm_sec = src->tm_sec;
2081 dest->tm_min = src->tm_min;
2082 dest->tm_hour = src->tm_hour;
2083 dest->tm_mday = src->tm_mday;
2084 dest->tm_mon = src->tm_mon;
2085 dest->tm_year = src->tm_year;
2086 dest->tm_isdst = src->tm_isdst;
2088 dest->TM_GMTOFF = src->TM_GMTOFF;
2097 const int_fast32_t offset,
2107 int_fast32_t y;
2124 y = yourtm.tm_year;
2125 if (normalize_overflow32(&y, &yourtm.tm_mon, MONSPERYEAR))
2128 ** Turn y into an actual year number for now.
2129 ** It is converted back to an offset from TM_YEAR_BASE later.
2131 if (increment_overflow32(&y, TM_YEAR_BASE))
2134 if (increment_overflow32(&y, -1))
2136 li = y + (1 < yourtm.tm_mon);
2140 li = y + (1 < yourtm.tm_mon);
2141 yourtm.tm_mday -= year_lengths[isleap(li)];
2142 if (increment_overflow32(&y, 1))
2146 i = mon_lengths[isleap(y)][yourtm.tm_mon];
2149 yourtm.tm_mday -= i;
2152 if (increment_overflow32(&y, 1))
2157 if (ckd_add(&yourtm.tm_year, y, -TM_YEAR_BASE))
2160 if (increment_overflow32(&y, -TM_YEAR_BASE))
2162 if (! (INT_MIN <= y && y <= INT_MAX))
2164 yourtm.tm_year = y;
2168 else if (yourtm.tm_year < EPOCH_YEAR - TM_YEAR_BASE) {
2177 if (increment_overflow(&yourtm.tm_sec, 1 - SECSPERMIN))
2180 yourtm.tm_sec = SECSPERMIN - 1;
2196 if (! funcp(sp, &t, offset, &mytm)) {
2202 dir = (t > 0) ? 1 : -1;
2213 --t;
2214 --hi;
2226 ? (-SECSPERDAY <= yourtm.TM_GMTOFF
2234 /* MYTM matches YOURTM except with the wrong UT offset.
2239 int_fast32_t diff = mytm.TM_GMTOFF - yourtm.TM_GMTOFF;
2242 if (funcp(sp, &altt, offset, &alttm)
2262 for (i = sp->typecnt - 1; i >= 0; --i) {
2263 if (sp->ttis[i].tt_isdst != yourtm.tm_isdst)
2265 for (j = sp->typecnt - 1; j >= 0; --j) {
2266 if (sp->ttis[j].tt_isdst == yourtm.tm_isdst)
2270 newt = (t + sp->ttis[j].tt_utoff
2271 - sp->ttis[i].tt_utoff);
2272 if (! funcp(sp, &newt, offset, &mytm))
2292 if (funcp(sp, &t, offset, tmp))
2302 const int_fast32_t offset,
2312 t = time2sub(tmp, funcp, sp, offset, okayp, false);
2313 return *okayp ? t : time2sub(tmp, funcp, sp, offset, okayp, true);
2321 const int_fast32_t offset)
2337 if (tmp->tm_isdst > 1)
2338 tmp->tm_isdst = 1;
2339 t = time2(tmp, funcp, sp, offset, &okay);
2342 if (tmp->tm_isdst < 0)
2347 tmp->tm_isdst = 0; /* reset to std and try again */
2359 for (i = 0; i < sp->typecnt; ++i)
2362 for (i = sp->timecnt - 1; i >= 0; --i)
2363 if (!seen[sp->types[i]] && !ttunspecified(sp, sp->types[i])) {
2364 seen[sp->types[i]] = true;
2365 types[nseen++] = sp->types[i];
2369 if (sp->ttis[samei].tt_isdst != tmp->tm_isdst)
2373 if (sp->ttis[otheri].tt_isdst == tmp->tm_isdst)
2375 tmp->tm_sec += (sp->ttis[otheri].tt_utoff
2376 - sp->ttis[samei].tt_utoff);
2377 tmp->tm_isdst = !tmp->tm_isdst;
2378 t = time2(tmp, funcp, sp, offset, &okay);
2381 tmp->tm_sec -= (sp->ttis[otheri].tt_utoff
2382 - sp->ttis[samei].tt_utoff);
2383 tmp->tm_isdst = !tmp->tm_isdst;
2417 return -1;
2432 tmp->tm_isdst = -1; /* in case it wasn't initialized */
2445 Callers can instead use mktime_z with a fixed-offset zone. */
2447 timeoff(struct tm *tmp, long offset)
2450 tmp->tm_isdst = 0;
2452 return time1(tmp, gmtsub, gmtptr, offset);
2461 tmcpy.tm_wday = -1;
2474 i = sp->leapcnt;
2475 while (--i >= 0) {
2476 lp = &sp->lsis[i];
2477 if (t >= lp->ls_trans)
2478 return lp->ls_corr;
2484 ** XXX--is the below the right way to conditionalize??
2508 return t - leapcorr(sp, t);
2517 return -1;
2533 time_t y;
2541 y = x - leapcorr(sp, x);
2542 if (y < t) {
2545 y = x - leapcorr(sp, x);
2546 } while (y < t);
2547 x -= y != t;
2548 } else if (y > t) {
2550 --x;
2551 y = x - leapcorr(sp, x);
2552 } while (y > t);
2553 x += y != t;
2564 return -1;
2603 if (r != (time_t) -1) {
2604 int_fast32_t offset = EPOCH_LOCAL ? (daylight ? timezone : altzone) : 0;
2605 if (increment_overflow32(&offset, -EPOCH_OFFSET)
2606 || increment_overflow_time(&r, offset)) {
2608 r = -1;