aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2023-03-17 17:47:15 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2023-03-17 17:47:19 -0400
commit3e59e5048d0f20debe4ad79b2e02ca2a76c5daed (patch)
tree2180e041471bef69c7f7b515ce65cd01be31c48d /src/include
parentcc1392d4aa5206d6b4dcc1b036f7a001bcac4197 (diff)
downloadpostgresql-3e59e5048d0f20debe4ad79b2e02ca2a76c5daed.tar.gz
postgresql-3e59e5048d0f20debe4ad79b2e02ca2a76c5daed.zip
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
Diffstat (limited to 'src/include')
-rw-r--r--src/include/utils/datetime.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/include/utils/datetime.h b/src/include/utils/datetime.h
index c8f78a9f1ec..a871e3223de 100644
--- a/src/include/utils/datetime.h
+++ b/src/include/utils/datetime.h
@@ -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);