53static const char gmt[] =
"GMT";
61#define TZDEFRULESTRING ",M3.2.0,M11.1.0"
128 for (
i = 1;
i < 4; ++
i)
154 for (
i = 1;
i < 8; ++
i)
222 sp->goback =
sp->goahead =
false;
293 for (
i = 0;
i <
sp->timecnt; ++
i)
309 sp->types[
i - 1] = 0;
318 for (
i = 0;
i <
sp->timecnt; ++
i)
320 unsigned char typ = *p++;
322 if (
sp->typecnt <=
typ)
328 for (
i = 0;
i <
sp->typecnt; ++
i)
346 for (
i = 0;
i <
sp->charcnt; ++
i)
352 for (
i = 0;
i <
sp->leapcnt; ++
i)
379 for (
i = 0;
i <
sp->typecnt; ++
i)
388 if (*p !=
true && *p !=
false)
390 ttisp->tt_ttisstd = *p++;
393 for (
i = 0;
i <
sp->typecnt; ++
i)
402 if (*p !=
true && *p !=
false)
404 ttisp->tt_ttisut = *p++;
411 if (
up->tzhead.tzh_version[0] ==
'\0')
417 up->buf[0] ==
'\n' &&
up->buf[
nread - 1] ==
'\n' &&
471 while (1 <
sp->timecnt
472 && (
sp->types[
sp->timecnt - 1]
473 ==
sp->types[
sp->timecnt - 2]))
478 || (
sp->ats[
sp->timecnt - 1]
486 sp->types[
sp->timecnt] = (
sp->typecnt
496 if (
sp->typecnt == 0)
500 for (
i = 1;
i <
sp->timecnt; ++
i)
507 for (
i =
sp->timecnt - 2;
i >= 0; --
i)
534 for (
i = 0;
i <
sp->timecnt; ++
i)
535 if (
sp->types[
i] == 0)
537 i =
i <
sp->timecnt ? -1 : 0;
548 if (!
sp->ttis[
i].tt_isdst)
564 while (
sp->ttis[
i].tt_isdst)
565 if (++
i >=
sp->typecnt)
619 &&
ap->tt_isdst ==
bp->tt_isdst
620 &&
ap->tt_ttisstd ==
bp->tt_ttisstd
621 &&
ap->tt_ttisut ==
bp->tt_ttisut
623 &
sp->chars[
bp->tt_desigidx])
630 {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
631 {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
670 while ((
c = *
strp) !=
'\0' &&
c != delim)
693 num = num * 10 + (
c -
'0');
763 else if (*
strp ==
'+')
792 else if (*
strp ==
'M')
857 switch (
rulep->r_type)
892 m1 = (
rulep->r_mon + 9) % 12 + 1;
893 yy0 = (
rulep->r_mon <= 2) ? (year - 1) : year;
896 dow = ((26 *
m1 - 2) / 10 +
920 for (
i = 0;
i <
rulep->r_mon - 1; ++
i)
996 sp->goback =
sp->goahead =
false;
1058 sp->defaulttype = 0;
1124 sp->ttis[0] =
sp->ttis[1];
1128 sp->goback =
sp->goahead =
true;
1146 for (
i = 0;
i <
sp->timecnt; ++
i)
1149 if (!
sp->ttis[
j].tt_isdst)
1152 -
sp->ttis[
j].tt_utoff;
1157 for (
i = 0;
i <
sp->timecnt; ++
i)
1160 if (
sp->ttis[
j].tt_isdst)
1163 -
sp->ttis[
j].tt_utoff;
1178 for (
i = 0;
i <
sp->timecnt; ++
i)
1181 sp->types[
i] =
sp->ttis[
j].tt_isdst;
1182 if (
sp->ttis[
j].tt_ttisut)
1199 if (
isdst && !
sp->ttis[
j].tt_ttisstd)
1211 if (
sp->ttis[
j].tt_isdst)
1223 sp->defaulttype = 0;
1232 sp->defaulttype = 0;
1261static struct pg_tm *
1263 struct pg_tm *
const tmp)
1273 (
sp->goahead && t >
sp->ats[
sp->timecnt - 1]))
1311 i =
sp->defaulttype;
1316 int hi =
sp->timecnt;
1320 int mid = (lo + hi) >> 1;
1327 i = (
int)
sp->types[lo - 1];
1359static struct pg_tm *
1405 return y / 4 -
y / 100 +
y / 400;
1416static struct pg_tm *
1440 && (
i == 0 ? 0 :
lp[-1].ls_corr) <
corr);
1586 if (t >=
lp->ls_trans)
1628 if (
sp->timecnt == 0)
1637 (
sp->goahead && t >
sp->ats[
sp->timecnt - 1]))
1680 if (t >=
sp->ats[
sp->timecnt - 1])
1683 i =
sp->types[
sp->timecnt - 1];
1695 *boundary =
sp->ats[0];
1706 int hi =
sp->timecnt - 1;
1710 int mid = (lo + hi) >> 1;
1719 j =
sp->types[
i - 1];
1723 *boundary =
sp->ats[
i];
1791 int hi =
sp->timecnt;
1795 int mid = (lo + hi) >> 1;
1809 for (
i = cutoff - 1;
i >= 0;
i--)
1835 for (
i = cutoff;
i <
sp->timecnt;
i++)
1895 for (
int i = 0;
i <
sp->typecnt;
i++)
1979 for (
i = 1;
i <
sp->typecnt;
i++)
1981 if (
sp->ttis[
i].tt_utoff !=
sp->ttis[0].tt_utoff)
2019 if (!
tt ||
tt->tm_sec != 0)
#define unconstify(underlying_type, expr)
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
#define POSTGRES_EPOCH_JDATE
void err(int eval, const char *fmt,...)
int pg_open_tzfile(const char *name, char *canonname)
int tzload(char const *name, char *canonname, struct state *sp, bool doextend)
static const char * getqzname(const char *strp, const int delim)
static struct pg_tm * localsub(struct state const *sp, pg_time_t const *timep, struct pg_tm *const tmp)
bool pg_tz_acceptable(pg_tz *tz)
static int leaps_thru_end_of(const int y)
static bool increment_overflow_time(pg_time_t *tp, int_fast32_t j)
bool pg_timezone_abbrev_is_known(const char *abbrev, bool *isfixed, long int *gmtoff, int *isdst, const pg_tz *tz)
static int tzloadbody(char const *name, char *canonname, struct state *sp, bool doextend, union local_storage *lsp)
int pg_next_dst_boundary(const pg_time_t *timep, long int *before_gmtoff, int *before_isdst, pg_time_t *boundary, long int *after_gmtoff, int *after_isdst, const pg_tz *tz)
const char * pg_get_timezone_name(pg_tz *tz)
static void init_ttinfo(struct ttinfo *s, int_fast32_t utoff, bool isdst, int desigidx)
static void gmtload(struct state *const sp)
static int leaps_thru_end_of_nonneg(int y)
bool pg_get_timezone_offset(const pg_tz *tz, long int *gmtoff)
static const char * getsecs(const char *strp, int_fast32_t *const secsp)
const char * pg_get_next_timezone_abbrev(int *indx, const pg_tz *tz)
static const char * getnum(const char *strp, int *const nump, const int min, const int max)
static int_fast64_t leapcorr(struct state const *sp, pg_time_t t)
static int_fast32_t transtime(const int year, const struct rule *const rulep, const int_fast32_t offset)
static bool differ_by_repeat(const pg_time_t t1, const pg_time_t t0)
static bool increment_overflow(int *ip, int j)
static struct pg_tm * gmtsub(pg_time_t const *timep, int_fast32_t offset, struct pg_tm *tmp)
static int_fast64_t detzcode64(const char *const codep)
static const char * getzname(const char *strp)
static struct pg_tm * timesub(pg_time_t const *timep, int_fast32_t offset, struct state const *sp, struct pg_tm *tmp)
static const char wildabbr[]
struct pg_tm * pg_localtime(const pg_time_t *timep, const pg_tz *tz)
static int_fast32_t detzcode(const char *const codep)
static const int year_lengths[2]
static const int mon_lengths[2][MONSPERYEAR]
struct pg_tm * pg_gmtime(const pg_time_t *timep)
bool pg_interpret_timezone_abbrev(const char *abbrev, const pg_time_t *timep, long int *gmtoff, int *isdst, const pg_tz *tz)
static bool typesequiv(struct state const *sp, int a, int b)
bool tzparse(const char *name, struct state *sp, bool lastditch)
static const char * getrule(const char *strp, struct rule *const rulep)
static const char * getoffset(const char *strp, int_fast32_t *const offsetp)
#define TWOS_COMPLEMENT(t)
#define SECSPERREPEAT_BITS
#define TYPE_SIGNED(type)
char TZname[TZ_STRLEN_MAX+1]
struct ttinfo ttis[TZ_MAX_TYPES]
char chars[BIGGEST(BIGGEST(TZ_MAX_CHARS+1, 4),(2 *(TZ_STRLEN_MAX+1)))]
pg_time_t ats[TZ_MAX_TIMES]
unsigned char types[TZ_MAX_TIMES]
struct local_storage::file_analysis u
static unsigned char desigidx[TZ_MAX_TYPES]
static zic_t corr[TZ_MAX_LEAPS]