diff options
author | Thomas G. Lockhart <lockhart@fourpalms.org> | 2001-12-29 18:31:48 +0000 |
---|---|---|
committer | Thomas G. Lockhart <lockhart@fourpalms.org> | 2001-12-29 18:31:48 +0000 |
commit | b5e23db43881af39d17aed5df2e90f9d4a352c26 (patch) | |
tree | ecba68021430a76ae02cd6a0ec819c7f9dcf3f0f /src/backend/utils/adt/timestamp.c | |
parent | 3e87bfc1f1fa4f32ca8a417d0b0064a5d2700d35 (diff) | |
download | postgresql-b5e23db43881af39d17aed5df2e90f9d4a352c26.tar.gz postgresql-b5e23db43881af39d17aed5df2e90f9d4a352c26.zip |
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).
Diffstat (limited to 'src/backend/utils/adt/timestamp.c')
-rw-r--r-- | src/backend/utils/adt/timestamp.c | 15 |
1 files changed, 13 insertions, 2 deletions
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; |