Re: tsrange format

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: tsrange format
Date: 2016-01-03 20:37:57
Message-ID: 568986A5.7000102@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2016-01-03 20:43:25 Re: Question -- Session Operations - Feasibility Of Proposed Synchronization Method?
Previous Message Steve Petrie, P.Eng. 2016-01-03 19:46:44 Question -- Session Operations - Feasibility Of Proposed Synchronization Method?