33#define UNCONST(a) unconstify(char *, a)
66#ifndef TZDEFRULESTRING
67#define TZDEFRULESTRING ",M3.2.0,M11.1.0"
168 minval = -1 - maxval,
172 for (
i = 1;
i < 4; ++
i)
197 for (
i = 1;
i < 8; ++
i)
273 sp->goback =
sp->goahead =
false;
309 char version =
up->tzhead.tzh_version[0];
365 for (
i = 0;
i <
sp->timecnt; ++
i)
381 sp->types[
i - 1] = 0;
390 for (
i = 0;
i <
sp->timecnt; ++
i)
392 unsigned char typ = *p++;
394 if (
sp->typecnt <=
typ)
400 for (
i = 0;
i <
sp->typecnt; ++
i)
427 for (
i = 0;
i <
sp->charcnt; ++
i)
480 for (
i = 0;
i <
sp->typecnt; ++
i)
489 if (*p !=
true && *p !=
false)
491 ttisp->tt_ttisstd = *p++;
494 for (
i = 0;
i <
sp->typecnt; ++
i)
503 if (*p !=
true && *p !=
false)
505 ttisp->tt_ttisut = *p++;
518 up->buf[0] ==
'\n' &&
up->buf[
nread - 1] ==
'\n' &&
555 char *
cp =
sp->chars +
j;
575 while (1 <
sp->timecnt
576 && (
sp->types[
sp->timecnt - 1]
577 ==
sp->types[
sp->timecnt - 2]))
595 sp->ats[
sp->timecnt] = t;
596 sp->types[
sp->timecnt] = (
sp->typecnt
605 if (
sp->typecnt == 0)
629 {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
630 {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
641 return '0' <=
c &&
c <=
'9';
676 while ((
c = *
strp) !=
'\0' &&
c != delim)
699 num = num * 10 + (
c -
'0');
770 else if (*
strp ==
'+')
800 else if (*
strp ==
'M')
864 switch (
rulep->r_type)
899 m1 = (
rulep->r_mon + 9) % 12 + 1;
900 yy0 = (
rulep->r_mon <= 2) ? (year - 1) : year;
903 dow = ((26 *
m1 - 2) / 10 +
927 for (
i = 0;
i <
rulep->r_mon - 1; ++
i)
986 if (0 <
basep->timecnt)
1000 sp->goback =
sp->goahead =
false;
1041 if (!(*
name ==
',' || *
name ==
';'))
1144 sp->ttis[0] =
sp->ttis[1];
1148 sp->goback =
sp->goahead =
true;
1185static struct pg_tm *
1187 struct pg_tm *
const tmp)
1197 (
sp->goahead && t >
sp->ats[
sp->timecnt - 1]))
1227#if defined ckd_add && defined ckd_sub
1256 int hi =
sp->timecnt;
1260 int mid = (lo + hi) >> 1;
1267 i =
sp->types[lo - 1];
1301static struct pg_tm *
1346 return y / 4 -
y / 100 +
y / 400;
1357static struct pg_tm *
1488 tmp->TM_GMTOFF = offset;
1563 if (
ls.ls_trans <= t)
1649 if (
sp->timecnt == 0)
1658 (
sp->goahead && t >
sp->ats[
sp->timecnt - 1]))
1701 if (t >=
sp->ats[
sp->timecnt - 1])
1704 i =
sp->types[
sp->timecnt - 1];
1716 *boundary =
sp->ats[0];
1727 int hi =
sp->timecnt - 1;
1731 int mid = (lo + hi) >> 1;
1740 j =
sp->types[
i - 1];
1744 *boundary =
sp->ats[
i];
1812 int hi =
sp->timecnt;
1816 int mid = (lo + hi) >> 1;
1830 for (
i = cutoff - 1;
i >= 0;
i--)
1856 for (
i = cutoff;
i <
sp->timecnt;
i++)
1916 for (
int i = 0;
i <
sp->typecnt;
i++)
2000 for (
i = 1;
i <
sp->typecnt;
i++)
2002 if (
sp->ttis[
i].tt_utoff !=
sp->ttis[0].tt_utoff)
2040 if (!
tt ||
tt->tm_sec != 0)
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)
static bool tzparse(const char *name, struct state *sp, struct state const *basep)
static int_fast32_2s detzcode(const char *const codep)
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)
bool pg_tzload(const char *name, char *canonname, struct state *sp)
bool pg_timezone_abbrev_is_known(const char *abbrev, bool *isfixed, long int *gmtoff, int *isdst, const pg_tz *tz)
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 bool increment_overflow_time(pg_time_t *tp, int_fast32_2s j)
static int_fast32_2s leapcorr(struct state const *sp, pg_time_t t)
static int tzload(char const *name, char *canonname, struct state *sp, char tzloadflags)
static void gmtload(struct state *const sp)
static int leapcount(ATTRIBUTE_MAYBE_UNUSED struct state const *sp)
bool pg_get_timezone_offset(const pg_tz *tz, long int *gmtoff)
static const char * getsecs(const char *strp, int_fast32_t *const secsp)
static bool is_digit(char c)
static ATTRIBUTE_PURE_114833 const char * getzname(const char *strp)
const char * pg_get_next_timezone_abbrev(int *indx, const pg_tz *tz)
static pg_time_t leaps_thru_end_of(pg_time_t y)
static const char * getnum(const char *strp, int *const nump, const int min, const int max)
static int tzloadbody(char const *name, char *canonname, struct state *sp, char tzloadflags, union local_storage **lspp)
static int_fast32_t transtime(const int year, const struct rule *const rulep, const int_fast32_t offset)
static bool increment_overflow(int *ip, int j)
static pg_time_t leaps_thru_end_of_nonneg(pg_time_t y)
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 void set_leapcount(ATTRIBUTE_MAYBE_UNUSED struct state *sp, ATTRIBUTE_MAYBE_UNUSED int leapcnt)
static struct pg_tm * timesub(pg_time_t const *timep, int_fast32_t offset, struct state const *sp, struct pg_tm *tmp)
static ATTRIBUTE_PURE_114833 const char * getqzname(const char *strp, const int delim)
static const char wildabbr[]
struct pg_tm * pg_localtime(const pg_time_t *timep, const pg_tz *tz)
static const int year_lengths[2]
static const int mon_lengths[2][MONSPERYEAR]
static void set_lsinfo(ATTRIBUTE_MAYBE_UNUSED struct state *sp, ATTRIBUTE_MAYBE_UNUSED int i, ATTRIBUTE_MAYBE_UNUSED struct lsinfo lsinfo)
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 void init_ttinfo(struct ttinfo *s, int_fast32_t utoff, bool isdst, desigidx_type desigidx)
static const char * getrule(const char *strp, struct rule *const rulep)
static const char * getoffset(const char *strp, int_fast32_t *const offsetp)
unsigned char desigidx_type
int_fast32_t int_fast32_2s
#define ATTRIBUTE_MAYBE_UNUSED
#define ATTRIBUTE_PURE_114833
#define TWOS_COMPLEMENT(type)
#define TYPE_SIGNED(type)
char TZname[TZ_STRLEN_MAX+1]
struct ttinfo ttis[TZ_MAX_TYPES]
pg_time_t ats[TZ_MAX_TIMES]
unsigned char types[TZ_MAX_TIMES]
char chars[Max(Max(TZ_MAX_CHARS+CHARS_EXTRA, sizeof "UTC"), 2 *(TZNAME_MAXIMUM+1))]
desigidx_type tt_desigidx
struct local_storage::file_analysis u
static unsigned char desigidx[TZ_MAX_TYPES]