mirror of
https://github.com/postgres/postgres.git
synced 2025-11-06 07:49:08 +03:00
Implement parse_datetime() function
This commit adds parse_datetime() function, which implements datetime parsing with extended features demanded by upcoming jsonpath .datetime() method: * Dynamic type identification based on template string, * Support for standard-conforming 'strict' mode, * Timezone offset is returned as separate value. Extracted from original patch by Nikita Glukhov, Teodor Sigaev, Oleg Bartunov. Revised by me. Discussion: https://postgr.es/m/fcc6fc6a-b497-f39a-923d-aa34d0c588e8%402ndQuadrant.com Discussion: https://postgr.es/m/CAPpHfdsZgYEra_PeCLGNoXOWYx6iU-S3wF8aX0ObQUcZU%2B4XTw%40mail.gmail.com Author: Nikita Glukhov, Teodor Sigaev, Oleg Bartunov, Alexander Korotkov Reviewed-by: Anastasia Lubennikova, Peter Eisentraut
This commit is contained in:
@@ -41,11 +41,6 @@
|
||||
#endif
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
/* common code for timetypmodin and timetztypmodin */
|
||||
static int32
|
||||
anytime_typmodin(bool istz, ArrayType *ta)
|
||||
@@ -1203,7 +1198,7 @@ time_in(PG_FUNCTION_ARGS)
|
||||
/* tm2time()
|
||||
* Convert a tm structure to a time data type.
|
||||
*/
|
||||
static int
|
||||
int
|
||||
tm2time(struct pg_tm *tm, fsec_t fsec, TimeADT *result)
|
||||
{
|
||||
*result = ((((tm->tm_hour * MINS_PER_HOUR + tm->tm_min) * SECS_PER_MINUTE) + tm->tm_sec)
|
||||
@@ -1379,7 +1374,7 @@ time_scale(PG_FUNCTION_ARGS)
|
||||
* have a fundamental tie together but rather a coincidence of
|
||||
* implementation. - thomas
|
||||
*/
|
||||
static void
|
||||
void
|
||||
AdjustTimeForTypmod(TimeADT *time, int32 typmod)
|
||||
{
|
||||
static const int64 TimeScales[MAX_TIME_PRECISION + 1] = {
|
||||
@@ -1957,7 +1952,7 @@ time_part(PG_FUNCTION_ARGS)
|
||||
/* tm2timetz()
|
||||
* Convert a tm structure to a time data type.
|
||||
*/
|
||||
static int
|
||||
int
|
||||
tm2timetz(struct pg_tm *tm, fsec_t fsec, int tz, TimeTzADT *result)
|
||||
{
|
||||
result->time = ((((tm->tm_hour * MINS_PER_HOUR + tm->tm_min) * SECS_PER_MINUTE) + tm->tm_sec) *
|
||||
|
||||
Reference in New Issue
Block a user