lestrrat-p5 / DateTime-Format-Pg

Other
2 stars 5 forks source link

`parse_interval` doesn't support the syntax in its entirety #5

Closed ralesk closed 9 years ago

ralesk commented 10 years ago

In particular, it is entirely possible in Postgres to reorder all valid bits of the interval definition:

postgres=> select '12:34:56 1 week'::interval;
    interval     
-----------------
 7 days 12:34:56
(1 row)

postgres=> select '12 hours 1 week 42 seconds 34 minutes'::interval;
    interval     
-----------------
 7 days 12:34:42
(1 row)

Though it is not allowed to define short time format together with textual time format:

postgres=> select '12:34:00 1 week 42 seconds'::interval;
ERROR:  invalid input syntax for type interval: "12:34:00 1 week 42 seconds"
LINE 1: select '12:34:00 1 week 42 seconds'::interval;
               ^
lestrrat commented 10 years ago

Per our discussion on Twitter, I haven't been using Postgres for the last 9 yrs or so, I really appreciate PR or at the very least, some tests.

ralesk commented 10 years ago

Sure :) The issues were more of a note to myself than a request for fixes. (Or well, if anyone's around and wants to tackle it, be my guest)

ralesk commented 9 years ago

I guess this can be closed now.