From 54c8e821b8313c78ba19653f74e83e956fdb8fe5 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Sat, 20 Dec 2003 15:32:55 +0000 Subject: In my mind there were two categories of open issues a) ones that are 100% backward (such as the comment about outputting this format) and b) ones that aren't (such as deprecating the current postgresql shorthand of '1Y1M'::interval = 1 year 1 minute in favor of the ISO-8601 'P1Y1M'::interval = 1 year 1 month. Attached is a patch that addressed all the discussed issues that did not break backward compatability, including the ability to output ISO-8601 compliant intervals by setting datestyle to iso8601basic. Interval values can now be written as ISO 8601 time intervals, using the "Format with time-unit designators". This format always starts with the character 'P', followed by a string of values followed by single character time-unit designators. A 'T' separates the date and time parts of the interval. Ron Mayer --- doc/src/sgml/datatype.sgml | 63 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) (limited to 'doc/src') diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml index 8bae619c3d0..562dbd64804 100644 --- a/doc/src/sgml/datatype.sgml +++ b/doc/src/sgml/datatype.sgml @@ -1,5 +1,5 @@ @@ -1785,6 +1785,57 @@ January 8 04:05:06 1999 PST p should be between 0 and 6, and defaults to the precision of the input literal. + + + + Alternatively, interval values can be written as + ISO 8601 time intervals, using the "Format with time-unit designators". + This format always starts with the character 'P', followed + by a string of values followed by single character time-unit designators. + A 'T' separates the date and time parts of the interval. + + + + Format: PnYnMnDTnHnMnS + + + In this format, 'n' gets replaced by a number, and + Y represents years, + M (in the date part) months, + D months, + H hours, + M (in the time part) minutes, + and S seconds. + + + + + Interval Example + + + + Traditional + ISO-8601 time-interval + + + + + 1 month + P1M + + + 1 hour 30 minutes + PT1H30M + + + 2 years 10 months 15 days 10 hours 30 minutes 20 seconds + P2Y10M15DT10H30M20S + + + +
+ + @@ -1941,6 +1992,11 @@ January 8 04:05:06 1999 PST regional style 17.12.1997 07:37:16.00 PST + + ISO8601basic + ISO 8601 basic format + 19971217T073716-08 + @@ -1997,6 +2053,11 @@ January 8 04:05:06 1999 PST + + If the datestyle is set to iso8601basic, the interval + output is a ISO-8601 time interval with time-unit designator (like P1Y6M or PT23H59M59S). + + The date/time styles can be selected by the user using the SET datestyle command, the -- cgit v1.2.3