From: | Dann Corbit <DCorbit(at)connx(dot)com> |
---|---|
To: | 'Andrew Dunstan' <andrew(at)dunslane(dot)net>, Francis Markham <fmarkham(at)gmail(dot)com> |
Cc: | "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Implementation of Date/Time Input Interpretation |
Date: | 2010-06-23 03:58:26 |
Message-ID: | 87F42982BF2B434F831FCEF4C45FC33E0C20103D@EXCHANGE.corporate.connx.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> -----Original Message-----
> From: Andrew Dunstan [mailto:andrew(at)dunslane(dot)net]
> Sent: Tuesday, June 22, 2010 7:47 PM
> To: Francis Markham
> Cc: Dann Corbit; pgsql-hackers(at)postgresql(dot)org
> Subject: Re: [HACKERS] Implementation of Date/Time Input Interpretation
>
>
>
> Francis Markham wrote:
> > Thank you for your prompt reply.
> >
> >
> >> What is it exactly that you are trying to accomplish?
> >>
> >
> > I want to be able to, from my own script, determine if postgres will
> > be able to interpret a string as a date or time. If you can suggest
> a
> > better way of accomplishing this beyond reimplementing your algorithm
> > I would be happy to hear it!
> >
> >
>
> Call the appropriate input function in plpgsql and trap a data
> exception? These routines are going to be quite hard to mimic, I
> suspect. Getting postgres to do the work for you is probably a better
> way to go if you can.
For the O.P.:
This is the specification of the input format that is needed for date/time values:
http://www.postgresql.org/docs/8.4/interactive/datatype-datetime.html
See also:
http://www.postgresql.org/docs/8.4/interactive/datetime-appendix.html
If he wants to be able to simply validate date/time values before insertion, I would suggest a package like libmcal and pick out the file datetime.c, in particular:
extern bool datevalid(int year,int mon,int mday);
extern bool timevalid(int hour,int min,int sec);
The PostgreSQL database routine has lots of fluff intended for interfacing with the database, etc. which makes a simpler approach easier if validation is what is wanted. Of course date/time/calendar libraries are available in just about every language.
From | Date | Subject | |
---|---|---|---|
Next Message | Fujii Masao | 2010-06-23 04:20:02 | Re: TCP keepalive support for libpq |
Previous Message | Andrew Dunstan | 2010-06-23 02:46:48 | Re: Implementation of Date/Time Input Interpretation |