diff options
author | Andrew Dunstan <andrew@dunslane.net> | 2018-01-16 19:07:13 -0500 |
---|---|---|
committer | Andrew Dunstan <andrew@dunslane.net> | 2018-01-16 19:07:13 -0500 |
commit | cc4feded0a31d2b732d4ea68613115cb720e624e (patch) | |
tree | a3e1a713c0a16cfb0dfbe02e9bf718fd56319adf /src/backend/utils/adt/date.c | |
parent | d91da5ecedc8f8965bd35de66b09feb79c26e5ca (diff) | |
download | postgresql-cc4feded0a31d2b732d4ea68613115cb720e624e.tar.gz postgresql-cc4feded0a31d2b732d4ea68613115cb720e624e.zip |
Centralize json and jsonb handling of datetime types
The creates a single function JsonEncodeDateTime which will format these
data types in an efficient and consistent manner. This will be all the
more important when we come to jsonpath so we don't have to implement yet
more code doing the same thing in two more places.
This also extends the code to handle time and timetz types which were
not previously handled specially. This requires exposing the time2tm and
timetz2tm functions.
Patch from Nikita Glukhov
Diffstat (limited to 'src/backend/utils/adt/date.c')
-rw-r--r-- | src/backend/utils/adt/date.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c index 95a999857c7..747ef497897 100644 --- a/src/backend/utils/adt/date.c +++ b/src/backend/utils/adt/date.c @@ -41,8 +41,6 @@ #endif -static int time2tm(TimeADT time, struct pg_tm *tm, fsec_t *fsec); -static int timetz2tm(TimeTzADT *time, struct pg_tm *tm, fsec_t *fsec, int *tzp); static int tm2time(struct pg_tm *tm, fsec_t fsec, TimeADT *result); static int tm2timetz(struct pg_tm *tm, fsec_t fsec, int tz, TimeTzADT *result); static void AdjustTimeForTypmod(TimeADT *time, int32 typmod); @@ -1249,7 +1247,7 @@ tm2time(struct pg_tm *tm, fsec_t fsec, TimeADT *result) * If out of this range, leave as UTC (in practice that could only happen * if pg_time_t is just 32 bits) - thomas 97/05/27 */ -static int +int time2tm(TimeADT time, struct pg_tm *tm, fsec_t *fsec) { tm->tm_hour = time / USECS_PER_HOUR; @@ -2073,7 +2071,7 @@ timetztypmodout(PG_FUNCTION_ARGS) /* timetz2tm() * Convert TIME WITH TIME ZONE data type to POSIX time structure. */ -static int +int timetz2tm(TimeTzADT *time, struct pg_tm *tm, fsec_t *fsec, int *tzp) { TimeOffset trem = time->time; |