53static const char gmt[] =
"GMT";
61#define TZDEFRULESTRING ",M3.2.0,M11.1.0"
127 result =
codep[0] & 0x7f;
128 for (
i = 1;
i < 4; ++
i)
129 result = (result << 8) | (
codep[
i] & 0xff);
153 result =
codep[0] & 0x7f;
154 for (
i = 1;
i < 8; ++
i)
155 result = (result << 8) | (
codep[
i] & 0xff);
221 sp->goback =
sp->goahead =
false;
292 for (
i = 0;
i <
sp->timecnt; ++
i)
308 sp->types[
i - 1] = 0;
317 for (
i = 0;
i <
sp->timecnt; ++
i)
319 unsigned char typ = *p++;
321 if (
sp->typecnt <=
typ)
327 for (
i = 0;
i <
sp->typecnt; ++
i)
345 for (
i = 0;
i <
sp->charcnt; ++
i)
351 for (
i = 0;
i <
sp->leapcnt; ++
i)
378 for (
i = 0;
i <
sp->typecnt; ++
i)
387 if (*p !=
true && *p !=
false)
389 ttisp->tt_ttisstd = *p++;
392 for (
i = 0;
i <
sp->typecnt; ++
i)
401 if (*p !=
true && *p !=
false)
403 ttisp->tt_ttisut = *p++;
410 if (
up->tzhead.tzh_version[0] ==
'\0')
416 up->buf[0] ==
'\n' &&
up->buf[
nread - 1] ==
'\n' &&
470 while (1 <
sp->timecnt
471 && (
sp->types[
sp->timecnt - 1]
472 ==
sp->types[
sp->timecnt - 2]))
477 || (
sp->ats[
sp->timecnt - 1]
485 sp->types[
sp->timecnt] = (
sp->typecnt
495 if (
sp->typecnt == 0)
499 for (
i = 1;
i <
sp->timecnt; ++
i)
506 for (
i =
sp->timecnt - 2;
i >= 0; --
i)
533 for (
i = 0;
i <
sp->timecnt; ++
i)
534 if (
sp->types[
i] == 0)
536 i =
i <
sp->timecnt ? -1 : 0;
547 if (!
sp->ttis[
i].tt_isdst)
563 while (
sp->ttis[
i].tt_isdst)
564 if (++
i >=
sp->typecnt)
616 result = (
ap->tt_utoff ==
bp->tt_utoff
617 &&
ap->tt_isdst ==
bp->tt_isdst
618 &&
ap->tt_ttisstd ==
bp->tt_ttisstd
619 &&
ap->tt_ttisut ==
bp->tt_ttisut
621 &
sp->chars[
bp->tt_desigidx])
628 {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
629 {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
668 while ((
c = *
strp) !=
'\0' &&
c != delim)
691 num = num * 10 + (
c -
'0');
761 else if (*
strp ==
'+')
790 else if (*
strp ==
'M')
855 switch (
rulep->r_type)
890 m1 = (
rulep->r_mon + 9) % 12 + 1;
891 yy0 = (
rulep->r_mon <= 2) ? (year - 1) : year;
894 dow = ((26 *
m1 - 2) / 10 +
918 for (
i = 0;
i <
rulep->r_mon - 1; ++
i)
994 sp->goback =
sp->goahead =
false;
1056 sp->defaulttype = 0;
1122 sp->ttis[0] =
sp->ttis[1];
1126 sp->goback =
sp->goahead =
true;
1144 for (
i = 0;
i <
sp->timecnt; ++
i)
1147 if (!
sp->ttis[
j].tt_isdst)
1150 -
sp->ttis[
j].tt_utoff;
1155 for (
i = 0;
i <
sp->timecnt; ++
i)
1158 if (
sp->ttis[
j].tt_isdst)
1161 -
sp->ttis[
j].tt_utoff;
1176 for (
i = 0;
i <
sp->timecnt; ++
i)
1179 sp->types[
i] =
sp->ttis[
j].tt_isdst;
1180 if (
sp->ttis[
j].tt_ttisut)
1197 if (
isdst && !
sp->ttis[
j].tt_ttisstd)
1209 if (
sp->ttis[
j].tt_isdst)
1221 sp->defaulttype = 0;
1230 sp->defaulttype = 0;
1259static struct pg_tm *
1261 struct pg_tm *
const tmp)
1265 struct pg_tm *result;
1271 (
sp->goahead && t >
sp->ats[
sp->timecnt - 1]))
1309 i =
sp->defaulttype;
1314 int hi =
sp->timecnt;
1318 int mid = (lo + hi) >> 1;
1325 i = (
int)
sp->types[lo - 1];
1357static struct pg_tm *
1361 struct pg_tm *result;
1403 return y / 4 -
y / 100 +
y / 400;
1414static struct pg_tm *
1438 && (
i == 0 ? 0 :
lp[-1].ls_corr) <
corr);
1584 if (t >=
lp->ls_trans)
1626 if (
sp->timecnt == 0)
1635 (
sp->goahead && t >
sp->ats[
sp->timecnt - 1]))
1678 if (t >=
sp->ats[
sp->timecnt - 1])
1681 i =
sp->types[
sp->timecnt - 1];
1693 *boundary =
sp->ats[0];
1704 int hi =
sp->timecnt - 1;
1708 int mid = (lo + hi) >> 1;
1717 j =
sp->types[
i - 1];
1721 *boundary =
sp->ats[
i];
1789 int hi =
sp->timecnt;
1793 int mid = (lo + hi) >> 1;
1807 for (
i = cutoff - 1;
i >= 0;
i--)
1833 for (
i = cutoff;
i <
sp->timecnt;
i++)
1868 bool result =
false;
1893 for (
int i = 0;
i <
sp->typecnt;
i++)
1977 for (
i = 1;
i <
sp->typecnt;
i++)
1979 if (
sp->ttis[
i].tt_utoff !=
sp->ttis[0].tt_utoff)
2017 if (!
tt ||
tt->tm_sec != 0)
#define unconstify(underlying_type, expr)
#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_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 int_fast64_t leapcorr(struct state const *sp, pg_time_t)
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]