Re: Inputting relative datetimes
От | Dean Rasheed |
---|---|
Тема | Re: Inputting relative datetimes |
Дата | |
Msg-id | CAEZATCVsZyme9pFFousWdHdTQhxv-m0vzsq6y5zHw6BdWZ7WqA@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Inputting relative datetimes (Peter Eisentraut <peter_e@gmx.net>) |
Список | 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 по дате отправления: