Re: BUG #1757: timestamp 'epoch' is not absolute

Lists: pgsql-bugs
From: "Bennett, Steve" <s(dot)bennett(at)lancaster(dot)ac(dot)uk>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #1757: timestamp 'epoch' is not absolute
Date: 2005-07-07 20:30:58
Message-ID: 7F332A8009EE5D4CB62C87717A3498A10E49D25F@exchange-be1.lancs.ac.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs


> > It appears that the timestamp 'epoch' is being interpreted as
> > relative to the local timezone, rather than being an absolute time.
>
> This is correct for timestamp ... you want timestamp with time zone.

Sorry, but that's dumb (IMHO). The unix epoch is not relative to the
local timezone.

I'm now using a function to convert from unix times to timestamps, since
the alternative is ugly and verbose even by SQL standards...

create function epoch(integer)
returns timestamp with time zone
as 'select timestamp with time zone \'epoch\'
+ interval \'1 second\' * $1;'
language sql immutable;

Is there a better way?

Steve.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Bennett, Steve" <s(dot)bennett(at)lancaster(dot)ac(dot)uk>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #1757: timestamp 'epoch' is not absolute
Date: 2005-07-07 20:52:19
Message-ID: 5178.1120769539@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

"Bennett, Steve" <s(dot)bennett(at)lancaster(dot)ac(dot)uk> writes:
>>> It appears that the timestamp 'epoch' is being interpreted as
>>> relative to the local timezone, rather than being an absolute time.
>>
>> This is correct for timestamp ... you want timestamp with time zone.

> Sorry, but that's dumb (IMHO). The unix epoch is not relative to the
> local timezone.

Sorry, but you're out of luck on that. A timestamp without time zone
cannot represent any absolute time at all --- assuming that it does
amounts to ascribing a timezone to it, which we don't do in general.

Perhaps it would make more sense to refuse the "epoch" keyword in the
context of timestamp without timezone ...

> create function epoch(integer)
> returns timestamp with time zone
> as 'select timestamp with time zone \'epoch\'
> + interval \'1 second\' * $1;'
> language sql immutable;

> Is there a better way?

You might want to call this to_timestamp(), since that's what it's going
to be called in 8.1 ;-)

regards, tom lane