Integer input functions for date and timestamp - Mailing list pgsql-hackers

From Brendan Jurd
Subject Integer input functions for date and timestamp
Date
Msg-id AANLkTi=W1wtcL7qR4PuQaQ=UoabmjSUSz6QGJTUCXF-P@mail.gmail.com
Whole thread Raw
Responses Re: Integer input functions for date and timestamp
Re: Integer input functions for date and timestamp
Re: Integer input functions for date and timestamp
List pgsql-hackers
Hi folks,

In my own databases, I've been using a couple of C functions that
might be useful to the wider community.

They are very simple date/timestamp constructors that take integers as
their arguments.  Nothing fancy, but very convenient and *much* faster
than using a SQL or PL/pgSQL workaround.

The offering is analogous to mktime() in C/PHP, the standard datetime
constructors in Python, and Perl's Time::Local.  The function
signatures pretty much speak for themselves:

date(year int, month int, day int) returns date
datetime(year int, month int, day int, hour int, minute int, second
int) returns timestamp

Without these functions (or some variation), a user wishing to
construct a date from integers can only assemble the date into a
string and then put that string through postgres' datetime parser,
which is totally perverse.

Is there any interest in adding this to core, or failing that,
contrib?  If so I'd be happy to provide a patch including the
functions themselves and some attendant documentation.

I'm not wedded to the function names or argument order, and I realise
a fully realised offering would need to include a variant for
'timestamp with time zone'.

Cheers,
BJ


pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Extensions, this time with a patch
Next
From: Peter Geoghegan
Date:
Subject: Re: Integer input functions for date and timestamp