PostgreSQL Source Code
git master
|
#include "postgres_fe.h"
#include <time.h>
#include <ctype.h>
#include <math.h>
#include "common/string.h"
#include "dt.h"
#include "pgtypes_timestamp.h"
#include "pgtypeslib_extern.h"
Go to the source code of this file.
Typedefs | |
typedef long | AbsoluteTime |
Functions | |
static const datetkn * | datebsearch (const char *key, const datetkn *base, unsigned int nel) |
int | DecodeUnits (int field, char *lowtoken, int *val) |
int | date2j (int y, int m, int d) |
void | j2date (int jd, int *year, int *month, int *day) |
static int | DecodeSpecial (int field, char *lowtoken, int *val) |
void | EncodeDateOnly (struct tm *tm, int style, char *str, bool EuroDates) |
void | TrimTrailingZeros (char *str) |
void | EncodeDateTime (struct tm *tm, fsec_t fsec, bool print_tz, int tz, const char *tzn, int style, char *str, bool EuroDates) |
int | GetEpochTime (struct tm *tm) |
static void | abstime2tm (AbsoluteTime _time, int *tzp, struct tm *tm, char **tzn) |
void | GetCurrentDateTime (struct tm *tm) |
void | dt2time (double jd, int *hour, int *min, int *sec, fsec_t *fsec) |
static int | DecodeNumberField (int len, char *str, int fmask, int *tmask, struct tm *tm, fsec_t *fsec, bool *is2digits) |
static int | DecodeNumber (int flen, char *str, int fmask, int *tmask, struct tm *tm, fsec_t *fsec, bool *is2digits, bool EuroDates) |
static int | DecodeDate (char *str, int fmask, int *tmask, struct tm *tm, bool EuroDates) |
int | DecodeTime (char *str, int *tmask, struct tm *tm, fsec_t *fsec) |
static int | DecodeTimezone (char *str, int *tzp) |
static int | DecodePosixTimezone (char *str, int *tzp) |
int | ParseDateTime (char *timestr, char *lowstr, char **field, int *ftype, int *numfields, char **endstr) |
int | DecodeDateTime (char **field, int *ftype, int nf, int *dtype, struct tm *tm, fsec_t *fsec, bool EuroDates) |
static char * | find_end_token (char *str, char *fmt) |
static int | pgtypes_defmt_scan (union un_fmt_comb *scan_val, int scan_type, char **pstr, char *pfmt) |
int | PGTYPEStimestamp_defmt_scan (char **str, char *fmt, timestamp *d, int *year, int *month, int *day, int *hour, int *minute, int *second, int *tz) |
Variables | |
const int | day_tab [2][13] |
static const datetkn | datetktbl [] |
static const datetkn | deltatktbl [] |
static const unsigned int | szdatetktbl = lengthof(datetktbl) |
static const unsigned int | szdeltatktbl = lengthof(deltatktbl) |
static const datetkn * | datecache [MAXDATEFIELDS] = {NULL} |
static const datetkn * | deltacache [MAXDATEFIELDS] = {NULL} |
char * | months [] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL} |
char * | days [] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", NULL} |
char * | pgtypes_date_weekdays_short [] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", NULL} |
char * | pgtypes_date_months [] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", NULL} |
typedef long AbsoluteTime |
Definition at line 18 of file dt_common.c.
|
static |
Definition at line 973 of file dt_common.c.
References MAXTZLEN, PGTYPES_TS_BAD_TIMESTAMP, SECS_PER_HOUR, strlcpy(), TIMEZONE_GLOBAL, tm, pg_tm::tm_gmtoff, 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, pg_tm::tm_zone, and TZNAME_GLOBAL.
Referenced by GetCurrentDateTime().
int date2j | ( | int | y, |
int | m, | ||
int | d | ||
) |
Definition at line 581 of file dt_common.c.
References y.
Referenced by DecodeDateTime(), DecodeNumber(), and EncodeDateTime().
|
static |
Definition at line 502 of file dt_common.c.
References sort-test::key, and TOKMAXLEN.
Referenced by DecodeSpecial(), and DecodeUnits().
|
static |
Definition at line 1308 of file dt_common.c.
References ADBC, BC, DecodeNumber(), DecodeSpecial(), DOY, DTK_DATE_M, DTK_M, i, IGNORE_DTF, len, MAXDATEFIELDS, MONTH, str, tm, pg_tm::tm_mon, pg_tm::tm_year, type, TZ, and val.
Referenced by DecodeDateTime().
int DecodeDateTime | ( | char ** | field, |
int * | ftype, | ||
int | nf, | ||
int * | dtype, | ||
struct tm * | tm, | ||
fsec_t * | fsec, | ||
bool | EuroDates | ||
) |
Definition at line 1782 of file dt_common.c.
References ADBC, AM, AMPM, BC, date2j(), DAY, day_tab, DecodeDate(), DecodeNumber(), DecodeNumberField(), DecodePosixTimezone(), DecodeSpecial(), DecodeTime(), DecodeTimezone(), DOW, dt2time(), DTK_DATE, DTK_DATE_M, DTK_DAY, DTK_HOUR, DTK_JULIAN, DTK_M, DTK_MINUTE, DTK_MONTH, DTK_NOW, DTK_NUMBER, DTK_SECOND, DTK_SPECIAL, DTK_STRING, DTK_TIME, DTK_TIME_M, DTK_TODAY, DTK_TOMORROW, DTK_TZ, DTK_YEAR, DTK_YESTERDAY, DTK_ZULU, DTZ, DTZMOD, GetCurrentDateTime(), HOUR, HR24, i, IGNORE_DTF, isleap, ISOTIME, j2date(), MINUTE, MONTH, PM, RESERV, SECOND, strtoint(), 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, USECS_PER_DAY, val, value, and YEAR.
|
static |
Definition at line 1199 of file dt_common.c.
References date2j(), DAY, DecodeNumberField(), DOY, DTK_DATE_M, DTK_M, j2date(), MONTH, MONTHS_PER_YEAR, 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(), and DecodeDateTime().
|
static |
Definition at line 1089 of file dt_common.c.
References DTK_DATE, DTK_DATE_M, DTK_TIME, DTK_TIME_M, i, len, str, strtoint(), 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(), and DecodeNumber().
|
static |
Definition at line 1547 of file dt_common.c.
References DecodeSpecial(), DecodeTimezone(), DTZ, MAXDATEFIELDS, str, type, TZ, and val.
Referenced by DecodeDateTime().
|
static |
Definition at line 635 of file dt_common.c.
References datebsearch(), datecache, datetktbl, szdatetktbl, token, TOKMAXLEN, type, datetkn::type, UNKNOWN_FIELD, val, and datetkn::value.
Referenced by DecodeDate(), DecodeDateTime(), and DecodePosixTimezone().
Definition at line 1437 of file dt_common.c.
References DTK_TIME_M, i, str, strtoint(), tm, pg_tm::tm_hour, pg_tm::tm_min, pg_tm::tm_sec, and USECS_PER_SEC.
Referenced by DecodeDateTime().
|
static |
Definition at line 1502 of file dt_common.c.
References len, MINS_PER_HOUR, SECS_PER_MINUTE, str, and strtoint().
Referenced by DecodeDateTime(), DecodePosixTimezone(), and PGTYPEStimestamp_defmt_scan().
int DecodeUnits | ( | int | field, |
char * | lowtoken, | ||
int * | val | ||
) |
Definition at line 536 of file dt_common.c.
References datebsearch(), deltacache, deltatktbl, szdeltatktbl, token, TOKMAXLEN, type, datetkn::type, UNKNOWN_FIELD, val, and datetkn::value.
void dt2time | ( | double | jd, |
int * | hour, | ||
int * | min, | ||
int * | sec, | ||
fsec_t * | fsec | ||
) |
Definition at line 1068 of file dt_common.c.
References USECS_PER_HOUR, USECS_PER_MINUTE, and USECS_PER_SEC.
Referenced by DecodeDateTime().
void EncodeDateOnly | ( | struct tm * | tm, |
int | style, | ||
char * | str, | ||
bool | EuroDates | ||
) |
Definition at line 669 of file dt_common.c.
References Assert, MONTHS_PER_YEAR, sprintf, str, tm, pg_tm::tm_mday, pg_tm::tm_mon, pg_tm::tm_year, USE_GERMAN_DATES, USE_ISO_DATES, USE_POSTGRES_DATES, and USE_SQL_DATES.
void EncodeDateTime | ( | struct tm * | tm, |
fsec_t | fsec, | ||
bool | print_tz, | ||
int | tz, | ||
const char * | tzn, | ||
int | style, | ||
char * | str, | ||
bool | EuroDates | ||
) |
Definition at line 753 of file dt_common.c.
References date2j(), days, MAXTZLEN, MINS_PER_HOUR, months, SECS_PER_HOUR, 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_sec, pg_tm::tm_wday, pg_tm::tm_year, TrimTrailingZeros(), USE_GERMAN_DATES, USE_ISO_DATES, USE_POSTGRES_DATES, and USE_SQL_DATES.
|
static |
void GetCurrentDateTime | ( | struct tm * | tm | ) |
Definition at line 1060 of file dt_common.c.
References abstime2tm(), and tm.
Referenced by DecodeDateTime().
int GetEpochTime | ( | struct tm * | tm | ) |
Definition at line 949 of file dt_common.c.
References epoch, 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.
void j2date | ( | int | jd, |
int * | year, | ||
int * | month, | ||
int * | day | ||
) |
Definition at line 606 of file dt_common.c.
References y.
Referenced by DecodeDateTime(), and DecodeNumber().
int ParseDateTime | ( | char * | timestr, |
char * | lowstr, | ||
char ** | field, | ||
int * | ftype, | ||
int * | numfields, | ||
char ** | endstr | ||
) |
Definition at line 1600 of file dt_common.c.
References DTK_DATE, DTK_NUMBER, DTK_SPECIAL, DTK_STRING, DTK_TIME, DTK_TZ, MAXDATEFIELDS, and pg_tolower().
|
static |
Definition at line 2459 of file dt_common.c.
References err(), find_end_token(), un_fmt_comb::luint_val, pgtypes_strdup(), PGTYPES_TYPE_STRING_MALLOCED, PGTYPES_TYPE_UINT, PGTYPES_TYPE_UINT_LONG, un_fmt_comb::str_val, and un_fmt_comb::uint_val.
Referenced by PGTYPEStimestamp_defmt_scan().
int PGTYPEStimestamp_defmt_scan | ( | char ** | str, |
char * | fmt, | ||
timestamp * | d, | ||
int * | year, | ||
int * | month, | ||
int * | day, | ||
int * | hour, | ||
int * | minute, | ||
int * | second, | ||
int * | tz | ||
) |
Definition at line 2521 of file dt_common.c.
References datetktbl, day_tab, days, DecodeTimezone(), DTZ, err(), fmt, free, isleap, j, un_fmt_comb::luint_val, months, MONTHS_PER_YEAR, pg_strcasecmp(), pgtypes_alloc(), pgtypes_date_months, pgtypes_date_weekdays_short, pgtypes_defmt_scan(), PGTYPES_TYPE_STRING_MALLOCED, PGTYPES_TYPE_UINT, PGTYPES_TYPE_UINT_LONG, PGTYPEStimestamp_defmt_scan(), str, un_fmt_comb::str_val, szdatetktbl, tm, tm2timestamp(), pg_tm::tm_hour, pg_tm::tm_mday, pg_tm::tm_min, pg_tm::tm_mon, pg_tm::tm_sec, pg_tm::tm_year, token, type, TZ, un_fmt_comb::uint_val, and datetkn::value.
Referenced by PGTYPEStimestamp_defmt_asc(), and PGTYPEStimestamp_defmt_scan().
void TrimTrailingZeros | ( | char * | str | ) |
|
static |
Definition at line 489 of file dt_common.c.
Referenced by DecodeSpecial().
|
static |
Definition at line 20 of file dt_common.c.
Referenced by DecodeSpecial(), and PGTYPEStimestamp_defmt_scan().
const int day_tab[2][13] |
Definition at line 14 of file dt_common.c.
Referenced by DecodeDateTime(), and PGTYPEStimestamp_defmt_scan().
char* days[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", NULL} |
Definition at line 495 of file dt_common.c.
Referenced by EncodeDateTime(), and PGTYPEStimestamp_defmt_scan().
|
static |
Definition at line 491 of file dt_common.c.
Referenced by DecodeUnits().
|
static |
Definition at line 421 of file dt_common.c.
Referenced by DecodeUnits().
char* months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL} |
Definition at line 493 of file dt_common.c.
Referenced by EncodeDateTime(), and PGTYPEStimestamp_defmt_scan().
char* pgtypes_date_months[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", NULL} |
Definition at line 499 of file dt_common.c.
Referenced by dttofmtasc_replace(), PGTYPESdate_defmt_asc(), and PGTYPEStimestamp_defmt_scan().
char* pgtypes_date_weekdays_short[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", NULL} |
Definition at line 497 of file dt_common.c.
Referenced by dttofmtasc_replace(), PGTYPESdate_fmt_asc(), and PGTYPEStimestamp_defmt_scan().
Definition at line 486 of file dt_common.c.
Referenced by DecodeSpecial(), and PGTYPEStimestamp_defmt_scan().
|
static |
Definition at line 487 of file dt_common.c.
Referenced by DecodeUnits().