mirror of
https://github.com/postgres/postgres.git
synced 2026-01-29 12:02:15 +03:00
Refactor datetime functions' timezone lookup code to reduce duplication.
We already had five copies of essentially the same logic, and an upcoming patch introduces yet another use-case. That's past my threshold of pain, so introduce a common subroutine. There's not that much net code savings, but the chance of typos should go down. Inspired by a patch from Przemysław Sztoch, but different in detail. Discussion: https://postgr.es/m/01a84551-48dd-1359-bf7e-f6b0203a6bd0@sztoch.pl
This commit is contained in:
@@ -295,6 +295,11 @@ typedef struct DateTimeErrorExtra
|
||||
const char *dtee_abbrev; /* relevant time zone abbreviation */
|
||||
} DateTimeErrorExtra;
|
||||
|
||||
/* Result codes for DecodeTimezoneName() */
|
||||
#define TZNAME_FIXED_OFFSET 0
|
||||
#define TZNAME_DYNTZ 1
|
||||
#define TZNAME_ZONE 2
|
||||
|
||||
|
||||
extern void GetCurrentDateTime(struct pg_tm *tm);
|
||||
extern void GetCurrentTimeUsec(struct pg_tm *tm, fsec_t *fsec, int *tzp);
|
||||
@@ -340,6 +345,9 @@ extern int DecodeTimezoneAbbrev(int field, const char *lowtoken,
|
||||
extern int DecodeSpecial(int field, const char *lowtoken, int *val);
|
||||
extern int DecodeUnits(int field, const char *lowtoken, int *val);
|
||||
|
||||
extern int DecodeTimezoneName(const char *tzname, int *offset, pg_tz **tz);
|
||||
extern pg_tz *DecodeTimezoneNameToTz(const char *tzname);
|
||||
|
||||
extern int j2day(int date);
|
||||
|
||||
extern struct Node *TemporalSimplify(int32 max_precis, struct Node *node);
|
||||
|
||||
Reference in New Issue
Block a user