On 01/03/2016 11:40 AM, Greg Jaskiewicz wrote:
Hi, Is it easily possible to supply and receive tsrange types in epoch values, or is it really all down always to string parsing?
AFAIK, not without resorting to a using some mishmash of EXTRACT, to_date() and casting.
As a general rule, I pass time in the app in epoch-float values, which is then converted by the presenter/controller layer to the right format used by views, whether that’s a html app or some other type of an app. After all, I don’t always need the date in the YYYY-MM-DD format, and I want to be independent from the server configuration. Any wisdom on that front please ?
The way I do it, is I have a helper function that normalizes date/times to one of two basic formats, mdy for users and iso for the internal Web part(namely JavaScript). This is using Django and hence Python, where I use the dateutil package(dateutil.readthedocs.org/en/latest/). It takes care of all the ugliness of parsing date/time strings. I went this route because dates and times can appear from a variety sources that are not the database and which I have no control over.
-- Adrian Klaver adrian.klaver@xxxxxxxxxxx -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general