The following bug has been logged online:
Bug reference: 1618
Logged by: Dennis Vshivkov
Email address: walrus(at)amur(dot)ru
PostgreSQL version: 7.4.6, 8.0.1
Operating system: Debian GNU/Linux, kernel 2.4
Description: EXTRACTing EPOCH from TIME WITH TIME ZONE is broken
Details:
SELECT EXTRACT(EPOCH FROM '15:00:00+12'::TIMETZ);
date_part
-----------
97200
(1 row)
It should rather have returned 10800.
[8.0.1|src/backend/utils/adt/date.c] timetz_part():
else if ((type == RESERV) && (val == DTK_EPOCH))
{
#ifdef HAVE_INT64_TIMESTAMP
result = ((time->time / 1000000e0) - time->zone);
#else
result = (time->time - time->zone);
#endif
}
Time zone component should be added, not subtracted.