Re: Inputting relative datetimes

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: Jeff MacDonald <jam(at)zoidtechnologies(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Inputting relative datetimes
Date: 2011-08-27 15:36:13
Message-ID: CAEZATCVCPoVnkL_sBOp1aF54WV-DWdYgbW5nS+SPnawMv=_NpQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 27 August 2011 14:29, Jeff MacDonald <jam(at)zoidtechnologies(dot)com> wrote:
> Greetings,
>
> On Thursday, August 25, 2011 05:39:09 AM Dean Rasheed wrote:
>> As background, I have an app that accepts user text input and casts it
>> to a timestamp in order to produce reports. I use PostgreSQL's
>> timestamp input conversion for this, since it gives a lot of
>> flexibility, and can parse pretty much anything the users throw at it.
>>
>> It is also handy that it recognizes special case values like "now",
>> "today", "tomorrow" and "yesterday". However, I can't see any way of
>> entering more general relative timestamps like "5 days ago" or "2
>> hours from now".
>>
>
> Years ago I wrapped 'getdate.y' from the CVS source code and made it into a
> python extension. It handles "+2 hours" or "next week", etc. I don't know much
> of anything about making pg contrib modules, but it should not be hard to do.
> The way it works is you pass in a string and it returns the unix timestamp.
>
> [...snipped...]

That sounds like a pretty good approach, and a contrib module might
well be the way to go.

I'm not sure how best to handle timezones though, since it's
hard-coded list probably won't match the timezones PostgreSQL knows
about. Maybe that doesn't matter, I'm not sure.

Regards,
Dean

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hitoshi Harada 2011-08-27 16:05:29 Re: Questions and experiences writing a Foreign Data Wrapper
Previous Message Dean Rasheed 2011-08-27 15:11:03 Re: Inputting relative datetimes