PostgreSQL Source Code git master
|
#include "postgres.h"
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include "access/htup_details.h"
#include "access/xact.h"
#include "common/int.h"
#include "common/string.h"
#include "funcapi.h"
#include "miscadmin.h"
#include "nodes/nodeFuncs.h"
#include "parser/scansup.h"
#include "utils/builtins.h"
#include "utils/date.h"
#include "utils/datetime.h"
#include "utils/guc.h"
#include "utils/tzparser.h"
Go to the source code of this file.
Data Structures | |
struct | TzAbbrevCache |
Macros | |
#define | APPEND_CHAR(bufptr, end, newchar) |
Typedefs | |
typedef struct TzAbbrevCache | TzAbbrevCache |
Functions | |
static int | DecodeNumber (int flen, char *str, bool haveTextMonth, int fmask, int *tmask, struct pg_tm *tm, fsec_t *fsec, bool *is2digits) |
static int | DecodeNumberField (int len, char *str, int fmask, int *tmask, struct pg_tm *tm, fsec_t *fsec, bool *is2digits) |
static int | DecodeTimeCommon (char *str, int fmask, int range, int *tmask, struct pg_itm *itm) |
static int | DecodeTime (char *str, int fmask, int range, int *tmask, struct pg_tm *tm, fsec_t *fsec) |
static int | DecodeTimeForInterval (char *str, int fmask, int range, int *tmask, struct pg_itm_in *itm_in) |
static const datetkn * | datebsearch (const char *key, const datetkn *base, int nel) |
static int | DecodeDate (char *str, int fmask, int *tmask, bool *is2digits, struct pg_tm *tm) |
static char * | AppendSeconds (char *cp, int sec, fsec_t fsec, int precision, bool fillzeros) |
static bool | int64_multiply_add (int64 val, int64 multiplier, int64 *sum) |
static bool | AdjustFractMicroseconds (double frac, int64 scale, struct pg_itm_in *itm_in) |
static bool | AdjustFractDays (double frac, int scale, struct pg_itm_in *itm_in) |
static bool | AdjustFractYears (double frac, int scale, struct pg_itm_in *itm_in) |
static bool | AdjustMicroseconds (int64 val, double fval, int64 scale, struct pg_itm_in *itm_in) |
static bool | AdjustDays (int64 val, int scale, struct pg_itm_in *itm_in) |
static bool | AdjustMonths (int64 val, struct pg_itm_in *itm_in) |
static bool | AdjustYears (int64 val, int scale, struct pg_itm_in *itm_in) |
static int | DetermineTimeZoneOffsetInternal (struct pg_tm *tm, pg_tz *tzp, pg_time_t *tp) |
static bool | DetermineTimeZoneAbbrevOffsetInternal (pg_time_t t, const char *abbr, pg_tz *tzp, int *offset, int *isdst) |
static pg_tz * | FetchDynamicTimeZone (TimeZoneAbbrevTable *tbl, const datetkn *tp, DateTimeErrorExtra *extra) |
int | date2j (int year, int month, int day) |
void | j2date (int jd, int *year, int *month, int *day) |
int | j2day (int date) |
void | GetCurrentDateTime (struct pg_tm *tm) |
void | GetCurrentTimeUsec (struct pg_tm *tm, fsec_t *fsec, int *tzp) |
static char * | AppendTimestampSeconds (char *cp, struct pg_tm *tm, fsec_t fsec) |
static int | ParseFraction (char *cp, double *frac) |
static int | ParseFractionalSecond (char *cp, fsec_t *fsec) |
int | ParseDateTime (const char *timestr, char *workbuf, size_t buflen, char **field, int *ftype, int maxfields, int *numfields) |
int | DecodeDateTime (char **field, int *ftype, int nf, int *dtype, struct pg_tm *tm, fsec_t *fsec, int *tzp, DateTimeErrorExtra *extra) |
int | DetermineTimeZoneOffset (struct pg_tm *tm, pg_tz *tzp) |
int | DetermineTimeZoneAbbrevOffset (struct pg_tm *tm, const char *abbr, pg_tz *tzp) |
int | DetermineTimeZoneAbbrevOffsetTS (TimestampTz ts, const char *abbr, pg_tz *tzp, int *isdst) |
static bool | TimeZoneAbbrevIsKnown (const char *abbr, pg_tz *tzp, bool *isfixed, int *offset, int *isdst) |
int | DecodeTimeOnly (char **field, int *ftype, int nf, int *dtype, struct pg_tm *tm, fsec_t *fsec, int *tzp, DateTimeErrorExtra *extra) |
int | ValidateDate (int fmask, bool isjulian, bool is2digits, bool bc, struct pg_tm *tm) |
int | DecodeTimezone (const char *str, int *tzp) |
int | DecodeTimezoneAbbrev (int field, const char *lowtoken, int *ftype, int *offset, pg_tz **tz, DateTimeErrorExtra *extra) |
void | ClearTimeZoneAbbrevCache (void) |
int | DecodeSpecial (int field, const char *lowtoken, int *val) |
int | DecodeTimezoneName (const char *tzname, int *offset, pg_tz **tz) |
pg_tz * | DecodeTimezoneNameToTz (const char *tzname) |
int | DecodeTimezoneAbbrevPrefix (const char *str, int *offset, pg_tz **tz) |
static void | ClearPgItmIn (struct pg_itm_in *itm_in) |
int | DecodeInterval (char **field, int *ftype, int nf, int range, int *dtype, struct pg_itm_in *itm_in) |
static int | ParseISO8601Number (char *str, char **endptr, int64 *ipart, double *fpart) |
static int | ISO8601IntegerWidth (char *fieldstart) |
int | DecodeISO8601Interval (char *str, int *dtype, struct pg_itm_in *itm_in) |
int | DecodeUnits (int field, const char *lowtoken, int *val) |
void | DateTimeParseError (int dterr, DateTimeErrorExtra *extra, const char *str, const char *datatype, Node *escontext) |
static char * | EncodeTimezone (char *str, int tz, int style) |
void | EncodeDateOnly (struct pg_tm *tm, int style, char *str) |
void | EncodeTimeOnly (struct pg_tm *tm, fsec_t fsec, bool print_tz, int tz, int style, char *str) |
void | EncodeDateTime (struct pg_tm *tm, fsec_t fsec, bool print_tz, int tz, const char *tzn, int style, char *str) |
static char * | AddISO8601IntPart (char *cp, int64 value, char units) |
static char * | AddPostgresIntPart (char *cp, int64 value, const char *units, bool *is_zero, bool *is_before) |
static char * | AddVerboseIntPart (char *cp, int64 value, const char *units, bool *is_zero, bool *is_before) |
void | EncodeInterval (struct pg_itm *itm, int style, char *str) |
static bool | CheckDateTokenTable (const char *tablename, const datetkn *base, int nel) |
bool | CheckDateTokenTables (void) |
Node * | TemporalSimplify (int32 max_precis, Node *node) |
TimeZoneAbbrevTable * | ConvertTimeZoneAbbrevs (struct tzEntry *abbrevs, int n) |
void | InstallTimeZoneAbbrevs (TimeZoneAbbrevTable *tbl) |
Datum | pg_timezone_abbrevs_zone (PG_FUNCTION_ARGS) |
Datum | pg_timezone_abbrevs_abbrevs (PG_FUNCTION_ARGS) |
Datum | pg_timezone_names (PG_FUNCTION_ARGS) |
Variables | |
const int | day_tab [2][13] |
const char *const | months [] |
const char *const | days [] |
static const datetkn | datetktbl [] |
static const int | szdatetktbl = sizeof datetktbl / sizeof datetktbl[0] |
static const datetkn | deltatktbl [] |
static const int | szdeltatktbl = sizeof deltatktbl / sizeof deltatktbl[0] |
static TimeZoneAbbrevTable * | zoneabbrevtbl = NULL |
static const datetkn * | datecache [MAXDATEFIELDS] = {NULL} |
static const datetkn * | deltacache [MAXDATEFIELDS] = {NULL} |
static TzAbbrevCache | tzabbrevcache [MAXDATEFIELDS] |
#define APPEND_CHAR | ( | bufptr, | |
end, | |||
newchar | |||
) |
typedef struct TzAbbrevCache TzAbbrevCache |
|
static |
Definition at line 4629 of file datetime.c.
References sprintf, and value.
Referenced by EncodeInterval().
|
static |
Definition at line 4639 of file datetime.c.
References sprintf, and value.
Referenced by EncodeInterval().
|
static |
Definition at line 4662 of file datetime.c.
References sprintf, and value.
Referenced by EncodeInterval().
Definition at line 643 of file datetime.c.
References days, pg_add_s32_overflow(), pg_mul_s32_overflow(), scale, pg_itm_in::tm_mday, and val.
Referenced by DecodeInterval(), and DecodeISO8601Interval().
|
static |
Definition at line 579 of file datetime.c.
References AdjustFractMicroseconds(), pg_add_s32_overflow(), scale, pg_itm_in::tm_mday, and USECS_PER_DAY.
Referenced by DecodeInterval(), and DecodeISO8601Interval().
Definition at line 547 of file datetime.c.
References pg_add_s64_overflow(), scale, and pg_itm_in::tm_usec.
Referenced by AdjustFractDays(), AdjustMicroseconds(), DecodeInterval(), and DecodeISO8601Interval().
|
static |
Definition at line 611 of file datetime.c.
References MONTHS_PER_YEAR, pg_add_s32_overflow(), scale, and pg_itm_in::tm_mon.
Referenced by DecodeInterval(), and DecodeISO8601Interval().
|
static |
Definition at line 628 of file datetime.c.
References AdjustFractMicroseconds(), int64_multiply_add(), scale, pg_itm_in::tm_usec, and val.
Referenced by DecodeInterval(), and DecodeISO8601Interval().
Definition at line 659 of file datetime.c.
References pg_add_s32_overflow(), pg_itm_in::tm_mon, and val.
Referenced by DecodeInterval(), and DecodeISO8601Interval().
Definition at line 671 of file datetime.c.
References pg_add_s32_overflow(), pg_mul_s32_overflow(), scale, pg_itm_in::tm_year, and val.
Referenced by DecodeInterval(), and DecodeISO8601Interval().
|
static |
Definition at line 458 of file datetime.c.
References Assert, pg_ultostr(), pg_ultostr_zeropad(), remainder, and value.
Referenced by AppendTimestampSeconds(), EncodeInterval(), and EncodeTimeOnly().
Definition at line 521 of file datetime.c.
References AppendSeconds(), MAX_TIMESTAMP_PRECISION, tm, and pg_tm::tm_sec.
Referenced by EncodeDateTime().
|
static |
Definition at line 4895 of file datetime.c.
References elog, i, LOG, token, and TOKMAXLEN.
Referenced by CheckDateTokenTables(), and ConvertTimeZoneAbbrevs().
bool CheckDateTokenTables | ( | void | ) |
Definition at line 4927 of file datetime.c.
References Assert, CheckDateTokenTable(), date2j(), datetktbl, deltatktbl, POSTGRES_EPOCH_JDATE, szdatetktbl, szdeltatktbl, and UNIX_EPOCH_JDATE.
Referenced by PostmasterMain().
|
inlinestatic |
Definition at line 3456 of file datetime.c.
References pg_itm_in::tm_mday, pg_itm_in::tm_mon, pg_itm_in::tm_usec, and pg_itm_in::tm_year.
Referenced by DecodeInterval(), and DecodeISO8601Interval().
void ClearTimeZoneAbbrevCache | ( | void | ) |
Definition at line 3221 of file datetime.c.
References tzabbrevcache.
Referenced by assign_timezone().
TimeZoneAbbrevTable * ConvertTimeZoneAbbrevs | ( | struct tzEntry * | abbrevs, |
int | n | ||
) |
Definition at line 4989 of file datetime.c.
References tzEntry::abbrev, TimeZoneAbbrevTable::abbrevs, Assert, CheckDateTokenTable(), DTZ, DYNTZ, guc_malloc(), i, tzEntry::is_dst, LOG, MAXALIGN, TimeZoneAbbrevTable::numabbrevs, tzEntry::offset, strlcpy(), TimeZoneAbbrevTable::tblsize, datetkn::token, TOKMAXLEN, datetkn::type, TZ, DynamicZoneAbbrev::tz, datetkn::value, DynamicZoneAbbrev::zone, and tzEntry::zone.
Referenced by load_tzoffsets().
int date2j | ( | int | year, |
int | month, | ||
int | day | ||
) |
Definition at line 296 of file datetime.c.
Referenced by CheckDateTokenTables(), date2isoweek(), date2isoyear(), date2isoyearday(), date_in(), DCH_to_char(), DecodeDateTime(), DetermineTimeZoneOffsetInternal(), EncodeDateTime(), extract_date(), GetSQLCurrentDate(), isoweek2j(), make_date(), make_timestamp_internal(), parse_datetime(), PGTYPESdate_dayofweek(), PGTYPESdate_defmt_asc(), PGTYPESdate_fmt_asc(), PGTYPESdate_from_asc(), PGTYPESdate_julmdy(), PGTYPESdate_mdyjul(), PGTYPESdate_to_asc(), PGTYPESdate_today(), timestamp2tm(), timestamp_date(), timestamp_part_common(), timestamp_pl_interval(), timestamp_to_char(), timestamptz_date(), timestamptz_part_common(), timestamptz_pl_interval_internal(), timestamptz_to_char(), tm2timestamp(), to_date(), and ValidateDate().
Definition at line 4269 of file datetime.c.
References sort-test::key, and TOKMAXLEN.
Referenced by DecodeSpecial(), DecodeTimezoneAbbrev(), DecodeTimezoneAbbrevPrefix(), DecodeUnits(), and ParseDateTime().
void DateTimeParseError | ( | int | dterr, |
DateTimeErrorExtra * | extra, | ||
const char * | str, | ||
const char * | datatype, | ||
Node * | escontext | ||
) |
Definition at line 4208 of file datetime.c.
References DateTimeErrorExtra::dtee_abbrev, DateTimeErrorExtra::dtee_timezone, DTERR_BAD_FORMAT, DTERR_BAD_TIMEZONE, DTERR_BAD_ZONE_ABBREV, DTERR_FIELD_OVERFLOW, DTERR_INTERVAL_OVERFLOW, DTERR_MD_FIELD_OVERFLOW, DTERR_TZDISP_OVERFLOW, errcode(), errdetail(), errhint(), errmsg(), errsave, and str.
Referenced by date_in(), DecodeTimezoneName(), do_to_timestamp(), interval_in(), pg_timezone_abbrevs_abbrevs(), time_in(), timestamp_in(), timestamptz_in(), and timetz_in().
|
static |
Definition at line 2442 of file datetime.c.
References DecodeNumber(), DecodeSpecial(), DOY, DTERR_BAD_FORMAT, DTK_DATE_M, DTK_M, i, IGNORE_DTF, len, MAXDATEFIELDS, MONTH, str, tm, pg_tm::tm_mon, type, TZ, and val.
Referenced by DecodeDateTime(), and DecodeTimeOnly().
int DecodeDateTime | ( | char ** | field, |
int * | ftype, | ||
int | nf, | ||
int * | dtype, | ||
struct pg_tm * | tm, | ||
fsec_t * | fsec, | ||
int * | tzp, | ||
DateTimeErrorExtra * | extra | ||
) |
Definition at line 988 of file datetime.c.
References ADBC, AM, AMPM, BC, date2j(), DAY, DecodeDate(), DecodeNumber(), DecodeNumberField(), DecodeSpecial(), DecodeTime(), DecodeTimezone(), DecodeTimezoneAbbrev(), DetermineTimeZoneAbbrevOffset(), DetermineTimeZoneOffset(), DOW, dt2time(), DateTimeErrorExtra::dtee_timezone, DTERR_BAD_FORMAT, DTERR_BAD_TIMEZONE, DTERR_FIELD_OVERFLOW, DTK_DATE, DTK_DATE_M, DTK_EARLY, DTK_EPOCH, DTK_JULIAN, DTK_LATE, DTK_M, DTK_NOW, DTK_NUMBER, DTK_SPECIAL, DTK_STRING, DTK_TIME, DTK_TIME_M, DTK_TODAY, DTK_TOMORROW, DTK_TZ, DTK_YESTERDAY, DTK_ZULU, DTZ, DTZMOD, DYNTZ, elog, ERROR, GetCurrentDateTime(), GetCurrentTimeUsec(), HOURS_PER_DAY, HR24, i, IGNORE_DTF, INTERVAL_FULL_RANGE, ISOTIME, j2date(), MONTH, ParseFraction(), pg_tzset(), PM, RESERV, session_timezone, strtoint(), time_overflows(), tm, pg_tm::tm_hour, pg_tm::tm_isdst, pg_tm::tm_mday, pg_tm::tm_min, pg_tm::tm_mon, pg_tm::tm_sec, pg_tm::tm_wday, pg_tm::tm_year, type, TZ, UNITS, UNKNOWN_FIELD, USECS_PER_DAY, val, ValidateDate(), and value.
Referenced by check_recovery_target_time(), date_in(), PGTYPESdate_from_asc(), PGTYPEStimestamp_from_asc(), timestamp_in(), and timestamptz_in().
int DecodeInterval | ( | char ** | field, |
int * | ftype, | ||
int | nf, | ||
int | range, | ||
int * | dtype, | ||
struct pg_itm_in * | itm_in | ||
) |
Definition at line 3480 of file datetime.c.
References AdjustDays(), AdjustFractDays(), AdjustFractMicroseconds(), AdjustFractYears(), AdjustMicroseconds(), AdjustMonths(), AdjustYears(), AGO, Assert, CENTURY, ClearPgItmIn(), DAY, DAYS_PER_MONTH, DECADE, DecodeSpecial(), DecodeTimeForInterval(), DecodeUnits(), DTERR_BAD_FORMAT, DTERR_FIELD_OVERFLOW, DTK_ALL_SECS_M, DTK_CENTURY, DTK_DATE, DTK_DATE_M, DTK_DAY, DTK_DECADE, DTK_DELTA, DTK_EARLY, DTK_HOUR, DTK_LATE, DTK_M, DTK_MICROSEC, DTK_MILLENNIUM, DTK_MILLISEC, DTK_MINUTE, DTK_MONTH, DTK_NUMBER, DTK_SECOND, DTK_SPECIAL, DTK_STRING, DTK_TIME, DTK_TIME_M, DTK_TZ, DTK_WEEK, DTK_YEAR, HOUR, i, IGNORE_DTF, INTERVAL_MASK, IntervalStyle, INTSTYLE_SQL_STANDARD, MICROSECOND, MILLENNIUM, MILLISECOND, MINUTE, MONTH, MONTHS_PER_YEAR, ParseFraction(), pg_add_s64_overflow(), PG_INT64_MIN, pg_mul_s64_overflow(), range(), RESERV, SECOND, strtoint(), pg_itm_in::tm_mday, pg_itm_in::tm_mon, pg_itm_in::tm_usec, pg_itm_in::tm_year, type, UNITS, UNKNOWN_FIELD, USECS_PER_DAY, USECS_PER_HOUR, USECS_PER_MINUTE, USECS_PER_SEC, val, WEEK, and YEAR.
Referenced by interval_in().
int DecodeISO8601Interval | ( | char * | str, |
int * | dtype, | ||
struct pg_itm_in * | itm_in | ||
) |
Definition at line 3945 of file datetime.c.
References AdjustDays(), AdjustFractDays(), AdjustFractMicroseconds(), AdjustFractYears(), AdjustMicroseconds(), AdjustMonths(), AdjustYears(), ClearPgItmIn(), DAYS_PER_MONTH, DTERR_BAD_FORMAT, DTERR_FIELD_OVERFLOW, DTK_DELTA, ISO8601IntegerWidth(), ParseISO8601Number(), str, USECS_PER_DAY, USECS_PER_HOUR, USECS_PER_MINUTE, USECS_PER_SEC, and val.
Referenced by interval_in().
|
static |
Definition at line 2771 of file datetime.c.
References DateOrder, DATEORDER_DMY, DATEORDER_YMD, DAY, DecodeNumberField(), DOY, DTERR_BAD_FORMAT, DTERR_FIELD_OVERFLOW, DTK_DATE_M, DTK_M, MONTH, ParseFractionalSecond(), str, strtoint(), tm, pg_tm::tm_mday, pg_tm::tm_mon, pg_tm::tm_yday, pg_tm::tm_year, val, and YEAR.
Referenced by DecodeDate(), DecodeDateTime(), and DecodeTimeOnly().
|
static |
Definition at line 2956 of file datetime.c.
References DTERR_BAD_FORMAT, DTK_DATE, DTK_DATE_M, DTK_TIME, DTK_TIME_M, len, str, tm, pg_tm::tm_hour, pg_tm::tm_mday, pg_tm::tm_min, pg_tm::tm_mon, pg_tm::tm_sec, and pg_tm::tm_year.
Referenced by DecodeDateTime(), DecodeNumber(), and DecodeTimeOnly().
int DecodeSpecial | ( | int | field, |
const char * | lowtoken, | ||
int * | val | ||
) |
Definition at line 3240 of file datetime.c.
References datebsearch(), datecache, datetktbl, szdatetktbl, datetkn::token, TOKMAXLEN, type, datetkn::type, UNKNOWN_FIELD, val, and datetkn::value.
Referenced by DecodeDate(), DecodeDateTime(), DecodeInterval(), DecodeTimeOnly(), extract_date(), interval_part_common(), time_part_common(), timestamp_part_common(), timestamptz_part_common(), and timetz_part_common().
|
static |
Definition at line 2716 of file datetime.c.
References DecodeTimeCommon(), DTERR_FIELD_OVERFLOW, range(), str, tm, pg_itm::tm_hour, pg_tm::tm_hour, pg_itm::tm_min, pg_tm::tm_min, pg_itm::tm_sec, pg_tm::tm_sec, and pg_itm::tm_usec.
Referenced by DecodeDateTime(), DecodeInterval(), and DecodeTimeOnly().
|
static |
Definition at line 2634 of file datetime.c.
References DTERR_BAD_FORMAT, DTERR_FIELD_OVERFLOW, DTK_TIME_M, INTERVAL_MASK, MINS_PER_HOUR, MINUTE, ParseFractionalSecond(), range(), SECOND, SECS_PER_MINUTE, str, strtoint(), pg_itm::tm_hour, pg_itm::tm_min, pg_itm::tm_sec, pg_itm::tm_usec, and USECS_PER_SEC.
Referenced by DecodeTime(), and DecodeTimeForInterval().
|
static |
Definition at line 2745 of file datetime.c.
References DecodeTimeCommon(), DTERR_FIELD_OVERFLOW, int64_multiply_add(), range(), str, pg_itm::tm_hour, pg_itm::tm_min, pg_itm::tm_sec, pg_itm::tm_usec, pg_itm_in::tm_usec, USECS_PER_HOUR, USECS_PER_MINUTE, and USECS_PER_SEC.
Referenced by DecodeInterval().
int DecodeTimeOnly | ( | char ** | field, |
int * | ftype, | ||
int | nf, | ||
int * | dtype, | ||
struct pg_tm * | tm, | ||
fsec_t * | fsec, | ||
int * | tzp, | ||
DateTimeErrorExtra * | extra | ||
) |
Definition at line 1908 of file datetime.c.
References ADBC, AM, AMPM, BC, DecodeDate(), DecodeNumber(), DecodeNumberField(), DecodeSpecial(), DecodeTime(), DecodeTimezone(), DecodeTimezoneAbbrev(), DetermineTimeZoneAbbrevOffset(), DetermineTimeZoneOffset(), dt2time(), DateTimeErrorExtra::dtee_timezone, DTERR_BAD_FORMAT, DTERR_BAD_TIMEZONE, DTERR_FIELD_OVERFLOW, DTK_DATE, DTK_DATE_M, DTK_JULIAN, DTK_M, DTK_NOW, DTK_NUMBER, DTK_SPECIAL, DTK_STRING, DTK_TIME, DTK_TIME_M, DTK_TZ, DTK_ZULU, DTZ, DTZMOD, DYNTZ, GetCurrentDateTime(), GetCurrentTimeUsec(), HOURS_PER_DAY, HR24, i, IGNORE_DTF, INTERVAL_FULL_RANGE, ISOTIME, j2date(), ParseFraction(), pg_get_timezone_offset(), pg_tzset(), PM, RESERV, session_timezone, strtoint(), time_overflows(), tm, pg_tm::tm_hour, pg_tm::tm_isdst, pg_tm::tm_mday, pg_tm::tm_min, pg_tm::tm_mon, pg_tm::tm_sec, pg_tm::tm_year, type, TZ, UNITS, UNKNOWN_FIELD, USECS_PER_DAY, val, ValidateDate(), and value.
Referenced by time_in(), and timetz_in().
int DecodeTimezone | ( | const char * | str, |
int * | tzp | ||
) |
Definition at line 3051 of file datetime.c.
References DTERR_BAD_FORMAT, DTERR_TZDISP_OVERFLOW, MAX_TZDISP_HOUR, MINS_PER_HOUR, SECS_PER_MINUTE, str, and strtoint().
Referenced by DecodeDateTime(), DecodeTimeOnly(), and parse_sane_timezone().
int DecodeTimezoneAbbrev | ( | int | field, |
const char * | lowtoken, | ||
int * | ftype, | ||
int * | offset, | ||
pg_tz ** | tz, | ||
DateTimeErrorExtra * | extra | ||
) |
Definition at line 3135 of file datetime.c.
References TzAbbrevCache::abbrev, TimeZoneAbbrevTable::abbrevs, datebsearch(), DTERR_BAD_ZONE_ABBREV, DTZ, DYNTZ, FetchDynamicTimeZone(), TzAbbrevCache::ftype, TimeZoneAbbrevTable::numabbrevs, TzAbbrevCache::offset, session_timezone, strlcpy(), TimeZoneAbbrevIsKnown(), TOKMAXLEN, datetkn::type, TzAbbrevCache::tz, TZ, tzabbrevcache, UNKNOWN_FIELD, datetkn::value, and zoneabbrevtbl.
Referenced by DecodeDateTime(), DecodeTimeOnly(), and DecodeTimezoneName().
int DecodeTimezoneAbbrevPrefix | ( | const char * | str, |
int * | offset, | ||
pg_tz ** | tz | ||
) |
Definition at line 3365 of file datetime.c.
References TimeZoneAbbrevTable::abbrevs, datebsearch(), DYNTZ, FetchDynamicTimeZone(), len, TimeZoneAbbrevTable::numabbrevs, pg_tolower(), session_timezone, str, TimeZoneAbbrevIsKnown(), TOKMAXLEN, datetkn::type, datetkn::value, and zoneabbrevtbl.
Referenced by DCH_from_char().
int DecodeTimezoneName | ( | const char * | tzname, |
int * | offset, | ||
pg_tz ** | tz | ||
) |
Definition at line 3282 of file datetime.c.
References DateTimeParseError(), DecodeTimezoneAbbrev(), downcase_truncate_identifier(), DTZ, DYNTZ, ereport, errcode(), errmsg(), ERROR, pg_tzset(), type, TZ, TZNAME_DYNTZ, TZNAME_FIXED_OFFSET, and TZNAME_ZONE.
Referenced by DecodeTimezoneNameToTz(), parse_sane_timezone(), timestamp_zone(), timestamptz_zone(), and timetz_zone().
pg_tz * DecodeTimezoneNameToTz | ( | const char * | tzname | ) |
Definition at line 3337 of file datetime.c.
References DecodeTimezoneName(), pg_tzset_offset(), and TZNAME_FIXED_OFFSET.
Referenced by lookup_timezone().
int DecodeUnits | ( | int | field, |
const char * | lowtoken, | ||
int * | val | ||
) |
Definition at line 4163 of file datetime.c.
References datebsearch(), deltacache, deltatktbl, szdeltatktbl, datetkn::token, TOKMAXLEN, type, datetkn::type, UNKNOWN_FIELD, val, and datetkn::value.
Referenced by DecodeInterval(), extract_date(), interval_part_common(), interval_trunc(), time_part_common(), timestamp_part_common(), timestamp_trunc(), timestamptz_part_common(), timestamptz_trunc_internal(), and timetz_part_common().
Definition at line 1756 of file datetime.c.
References DetermineTimeZoneAbbrevOffsetInternal(), DetermineTimeZoneOffsetInternal(), tm, and pg_tm::tm_isdst.
Referenced by DecodeDateTime(), DecodeTimeOnly(), do_to_timestamp(), parse_sane_timezone(), and timestamp_zone().
|
static |
Definition at line 1831 of file datetime.c.
References pg_interpret_timezone_abbrev(), pg_toupper(), strlcpy(), and TZ_STRLEN_MAX.
Referenced by DetermineTimeZoneAbbrevOffset(), and DetermineTimeZoneAbbrevOffsetTS().
int DetermineTimeZoneAbbrevOffsetTS | ( | TimestampTz | ts, |
const char * | abbr, | ||
pg_tz * | tzp, | ||
int * | isdst | ||
) |
Definition at line 1794 of file datetime.c.
References DetermineTimeZoneAbbrevOffsetInternal(), DetermineTimeZoneOffset(), ereport, errcode(), errmsg(), ERROR, timestamp2tm(), timestamptz_to_time_t(), tm, and pg_tm::tm_isdst.
Referenced by pg_timezone_abbrevs_abbrevs(), timestamptz_zone(), and timetz_zone().
Definition at line 1595 of file datetime.c.
References DetermineTimeZoneOffsetInternal(), and tm.
Referenced by date2timestamptz_opt_overflow(), DecodeDateTime(), DecodeTimeOnly(), DetermineTimeZoneAbbrevOffsetTS(), executeDateTimeMethod(), parse_sane_timezone(), time_timetz(), timestamp2timestamptz_opt_overflow(), timestamp_zone(), timestamptz_pl_interval_internal(), timestamptz_trunc_internal(), and to_timestamp().
|
static |
Definition at line 1617 of file datetime.c.
References date2j(), IS_VALID_JULIAN, MINS_PER_HOUR, pg_next_dst_boundary(), res, SECS_PER_DAY, SECS_PER_MINUTE, tm, pg_tm::tm_hour, pg_tm::tm_isdst, pg_tm::tm_mday, pg_tm::tm_min, pg_tm::tm_mon, pg_tm::tm_sec, pg_tm::tm_year, and UNIX_EPOCH_JDATE.
Referenced by DetermineTimeZoneAbbrevOffset(), and DetermineTimeZoneOffset().
void EncodeDateOnly | ( | struct pg_tm * | tm, |
int | style, | ||
char * | str | ||
) |
Definition at line 4343 of file datetime.c.
References Assert, DateOrder, DATEORDER_DMY, MONTHS_PER_YEAR, pg_ultostr_zeropad(), str, tm, pg_tm::tm_mday, pg_tm::tm_mon, pg_tm::tm_year, USE_GERMAN_DATES, USE_ISO_DATES, USE_POSTGRES_DATES, USE_SQL_DATES, and USE_XSD_DATES.
Referenced by date_out(), JsonEncodeDateTime(), map_sql_value_to_xml_value(), and PGTYPESdate_to_asc().
void EncodeDateTime | ( | struct pg_tm * | tm, |
fsec_t | fsec, | ||
bool | print_tz, | ||
int | tz, | ||
const char * | tzn, | ||
int | style, | ||
char * | str | ||
) |
Definition at line 4458 of file datetime.c.
References AppendTimestampSeconds(), Assert, date2j(), DateOrder, DATEORDER_DMY, days, EncodeTimezone(), j2day(), MAXTZLEN, months, MONTHS_PER_YEAR, pg_ultostr_zeropad(), sprintf, str, tm, pg_tm::tm_hour, pg_tm::tm_isdst, pg_tm::tm_mday, pg_tm::tm_min, pg_tm::tm_mon, pg_tm::tm_wday, pg_tm::tm_year, USE_GERMAN_DATES, USE_ISO_DATES, USE_POSTGRES_DATES, USE_SQL_DATES, and USE_XSD_DATES.
Referenced by JsonEncodeDateTime(), map_sql_value_to_xml_value(), PGTYPEStimestamp_to_asc(), timestamp_out(), timestamptz_out(), and timestamptz_to_str().
void EncodeInterval | ( | struct pg_itm * | itm, |
int | style, | ||
char * | str | ||
) |
Definition at line 4701 of file datetime.c.
References AddISO8601IntPart(), AddPostgresIntPart(), AddVerboseIntPart(), AppendSeconds(), INTSTYLE_ISO_8601, INTSTYLE_POSTGRES, INTSTYLE_POSTGRES_VERBOSE, INTSTYLE_SQL_STANDARD, MAX_INTERVAL_PRECISION, sprintf, str, pg_itm::tm_hour, pg_itm::tm_mday, pg_itm::tm_min, pg_itm::tm_mon, pg_itm::tm_sec, pg_itm::tm_usec, and pg_itm::tm_year.
Referenced by interval_out().
void EncodeTimeOnly | ( | struct pg_tm * | tm, |
fsec_t | fsec, | ||
bool | print_tz, | ||
int | tz, | ||
int | style, | ||
char * | str | ||
) |
Definition at line 4428 of file datetime.c.
References AppendSeconds(), EncodeTimezone(), MAX_TIME_PRECISION, pg_ultostr_zeropad(), str, tm, pg_tm::tm_hour, pg_tm::tm_min, and pg_tm::tm_sec.
Referenced by JsonEncodeDateTime(), time_out(), and timetz_out().
|
static |
Definition at line 4305 of file datetime.c.
References MINS_PER_HOUR, pg_ultostr_zeropad(), SECS_PER_MINUTE, str, and USE_XSD_DATES.
Referenced by EncodeDateTime(), and EncodeTimeOnly().
|
static |
Definition at line 5086 of file datetime.c.
References Assert, DateTimeErrorExtra::dtee_abbrev, DateTimeErrorExtra::dtee_timezone, DYNTZ, pg_tzset(), TimeZoneAbbrevTable::tblsize, datetkn::token, datetkn::type, DynamicZoneAbbrev::tz, datetkn::value, and DynamicZoneAbbrev::zone.
Referenced by DecodeTimezoneAbbrev(), DecodeTimezoneAbbrevPrefix(), and pg_timezone_abbrevs_abbrevs().
void GetCurrentDateTime | ( | struct pg_tm * | tm | ) |
Definition at line 376 of file datetime.c.
References GetCurrentTimeUsec(), and tm.
Referenced by DecodeDateTime(), DecodeTimeOnly(), GetSQLCurrentDate(), PGTYPESdate_today(), PGTYPEStimestamp_current(), and time_timetz().
Definition at line 397 of file datetime.c.
References ereport, errcode(), errmsg(), ERROR, GetCurrentTransactionStartTimestamp(), session_timezone, timestamp2tm(), and tm.
Referenced by DecodeDateTime(), DecodeTimeOnly(), GetCurrentDateTime(), GetSQLCurrentTime(), and GetSQLLocalTime().
void InstallTimeZoneAbbrevs | ( | TimeZoneAbbrevTable * | tbl | ) |
Definition at line 5073 of file datetime.c.
References tzabbrevcache, and zoneabbrevtbl.
Referenced by assign_timezone_abbreviations().
Definition at line 532 of file datetime.c.
References pg_add_s64_overflow(), pg_mul_s64_overflow(), and val.
Referenced by AdjustMicroseconds(), and DecodeTimeForInterval().
|
static |
Definition at line 3918 of file datetime.c.
Referenced by DecodeISO8601Interval().
void j2date | ( | int | jd, |
int * | year, | ||
int * | month, | ||
int * | day | ||
) |
Definition at line 321 of file datetime.c.
References MONTHS_PER_YEAR, and y.
Referenced by date2timestamptz_opt_overflow(), date_out(), DecodeDateTime(), DecodeTimeOnly(), do_to_timestamp(), executeDateTimeMethod(), extract_date(), isoweek2date(), isoweekdate2date(), JsonEncodeDateTime(), map_sql_value_to_xml_value(), PGTYPESdate_fmt_asc(), PGTYPESdate_julmdy(), PGTYPESdate_to_asc(), timestamp2tm(), timestamp_pl_interval(), timestamptz_pl_interval_internal(), and ValidateDate().
int j2day | ( | int | date | ) |
Definition at line 354 of file datetime.c.
Referenced by date2isoweek(), date2isoyear(), EncodeDateTime(), extract_date(), isoweek2j(), timestamp_part_common(), and timestamptz_part_common().
int ParseDateTime | ( | const char * | timestr, |
char * | workbuf, | ||
size_t | buflen, | ||
char ** | field, | ||
int * | ftype, | ||
int | maxfields, | ||
int * | numfields | ||
) |
Definition at line 764 of file datetime.c.
References APPEND_CHAR, datebsearch(), datetktbl, DTERR_BAD_FORMAT, DTK_DATE, DTK_NUMBER, DTK_SPECIAL, DTK_STRING, DTK_TIME, DTK_TZ, pg_tolower(), and szdatetktbl.
Referenced by check_recovery_target_time(), date_in(), interval_in(), PGTYPESdate_from_asc(), PGTYPESinterval_from_asc(), PGTYPEStimestamp_from_asc(), time_in(), timestamp_in(), timestamptz_in(), and timetz_in().
|
static |
Definition at line 690 of file datetime.c.
References Assert, and DTERR_BAD_FORMAT.
Referenced by DecodeDateTime(), DecodeInterval(), DecodeTimeOnly(), and ParseFractionalSecond().
|
static |
Definition at line 719 of file datetime.c.
References ParseFraction().
Referenced by DecodeNumber(), and DecodeTimeCommon().
|
static |
Definition at line 3876 of file datetime.c.
References Assert, DTERR_BAD_FORMAT, DTERR_FIELD_OVERFLOW, str, and val.
Referenced by DecodeISO8601Interval().
Datum pg_timezone_abbrevs_abbrevs | ( | PG_FUNCTION_ARGS | ) |
Definition at line 5205 of file datetime.c.
References TimeZoneAbbrevTable::abbrevs, BoolGetDatum(), CStringGetTextDatum, DateTimeParseError(), DetermineTimeZoneAbbrevOffsetTS(), DTERR_BAD_ZONE_ABBREV, DTZ, DYNTZ, elog, ERROR, FetchDynamicTimeZone(), get_call_result_type(), GetCurrentTransactionStartTimestamp(), heap_form_tuple(), HeapTupleGetDatum(), if(), IntervalPGetDatum(), itmin2interval(), MemoryContextSwitchTo(), MemSet, FuncCallContext::multi_call_memory_ctx, now(), TimeZoneAbbrevTable::numabbrevs, palloc(), pg_toupper(), SRF_FIRSTCALL_INIT, SRF_IS_FIRSTCALL, SRF_PERCALL_SETUP, SRF_RETURN_DONE, SRF_RETURN_NEXT, strlcpy(), pg_itm_in::tm_usec, datetkn::token, TOKMAXLEN, FuncCallContext::tuple_desc, datetkn::type, TYPEFUNC_COMPOSITE, TZ, USECS_PER_SEC, FuncCallContext::user_fctx, datetkn::value, values, and zoneabbrevtbl.
Datum pg_timezone_abbrevs_zone | ( | PG_FUNCTION_ARGS | ) |
Definition at line 5118 of file datetime.c.