tsrange format
tsrange format
От:
Greg Jaskiewicz <gryzman@gmail.com>
Дата:
Hi, Is it easily possible to supply and receive tsrange types in epoch values, or is it really all down always to string parsing? 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 ?
Re: tsrange format
От:
Adrian Klaver <adrian.klaver@aklaver.com>
Дата:
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@aklaver.com