From b5e23db43881af39d17aed5df2e90f9d4a352c26 Mon Sep 17 00:00:00 2001 From: "Thomas G. Lockhart" Date: Sat, 29 Dec 2001 18:31:48 +0000 Subject: Rework the date/time parsing to tighten up some cases and to enable other cases which should have worked but did not. Now supports julian day (J2452271), ISO time labels (T040506) and various combinations of spaces and run-togethers of dates, times, and time zones. All regression tests pass, and I have more tests to add after the 7.2 release (don't want to require changes to the ancillary horology result files until after then). --- src/backend/utils/adt/timestamp.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/backend/utils/adt/timestamp.c') diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index 490e7beb1d0..8056e3171a9 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.60 2001/11/21 18:29:48 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.61 2001/12/29 18:31:31 thomas Exp $ * *------------------------------------------------------------------------- */ @@ -2461,6 +2461,11 @@ timestamp_part(PG_FUNCTION_ARGS) result = (tm->tm_year / 1000); break; + case DTK_JULIAN: + result = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday); + result += (((((tm->tm_hour * 60) + tm->tm_min) * 60) + tm->tm_sec) / 86400e0); + break; + case DTK_TZ: case DTK_TZ_MINUTE: case DTK_TZ_HOUR: @@ -2549,7 +2554,8 @@ timestamptz_part(PG_FUNCTION_ARGS) PG_RETURN_FLOAT8(result); } - if ((type == UNITS) && (timestamp2tm(timestamp, &tz, tm, &fsec, &tzn) == 0)) + if ((type == UNITS) + && (timestamp2tm(timestamp, &tz, tm, &fsec, &tzn) == 0)) { switch (val) { @@ -2619,6 +2625,11 @@ timestamptz_part(PG_FUNCTION_ARGS) result = (tm->tm_year / 1000); break; + case DTK_JULIAN: + result = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday); + result += (((((tm->tm_hour * 60) + tm->tm_min) * 60) + tm->tm_sec) / 86400e0); + break; + default: elog(ERROR, "TIMESTAMP WITH TIME ZONE units '%s' not supported", lowunits); result = 0; -- cgit v1.2.3