Re: Inputting relative datetimes - Mailing list pgsql-hackers

From Dean Rasheed
Subject Re: Inputting relative datetimes
Date
Msg-id CAEZATCVsZyme9pFFousWdHdTQhxv-m0vzsq6y5zHw6BdWZ7WqA@mail.gmail.com
Whole thread Raw
In response to Re: Inputting relative datetimes  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
On 27 August 2011 14:14, Peter Eisentraut <peter_e@gmx.net> wrote:
> On lör, 2011-08-27 at 12:29 +0100, Dean Rasheed wrote:
>> So Robert and Merlin both expressed concerns that the existing
>> datetime string parsing code is so complicated that adding to it would
>> likely just introduce more bugs.
>>
>> My first thought was 'how hard can it be?' - famous last words :-)
>
> Maybe you can find an existing Perl or Python module that has already
> implemented this.  Then the solution might be 5 lines of wrapping this
> into a PostgreSQL function.
>

Ah now that's an interesting idea.

Python's dateutil module seems to come highly recommended, although I
don't find this too encouraging:

>>> dateutil.parser.parse('today', fuzzy=True)
datetime.datetime(2011, 8, 27, 0, 0)
>>> dateutil.parser.parse('tomorrow', fuzzy=True)
datetime.datetime(2011, 8, 27, 0, 0)
>>> dateutil.parser.parse('foobar', fuzzy=True)
datetime.datetime(2011, 8, 27, 0, 0)

Still, there might be something better out there...

Cheers,
Dean


pgsql-hackers by date:

Previous
From: Magnus Hagander
Date:
Subject: Re: Cryptic error message in low-memory conditions
Next
From: Dean Rasheed
Date:
Subject: Re: Inputting relative datetimes