Description
Submitted by: @mrotteveel
As a follow-up to the discussion on firebird-devel titled "Current timestamp without timezone in given timezone", I suggest that we add TIME and TIMESTAMP to EXTRACT to be able to extract the time in the zone of a WITH TIME ZONE type as a WITHOUT TIME ZONE type.
This would have the following semantics:
<part> from <datetime> => <resulttype>
TIME from timestamp_with_tz => time in zone (@ specified date) as TIME WITHOUT TIME ZONE
TIMESTAMP from timestamp_with_tz => time+date in zone as TIMESTAMP WITHOUT TIME ZONE
TIME from time_with_tz => time in zone as TIME WITHOUT TIME ZONE
TIMESTAMP from time_with_tz => time in zone @ current_date as TIMESTAMP WITHOUT TIME ZONE
TIME from timestamp_without_tz => cast to TIME WITHOUT TIME ZONE (strip date)
TIMESTAMP from timestamp_without_tz => original value (timestamp_without_tz )
TIME from time_without_tz => original value (time_without_tz)
TIMESTAMP from time_without_tz => cast to TIMESTAMP WITHOUT TIME ZONE (value @ current_date)
TIME from date_val => conversion error
TIMESTAMP from date_val => cast to TIMESTAMP WITHOUT TIME ZONE (current_date + 00:00:00 as time)
Primary rationale for this feature is that CAST(tz_value as TIME[STAMP] WITHOUT TIME ZONE) converts to the time in the session time zone before conversion to WITHOUT TIME ZONE. Currently, getting the time in the zone as a WITHOUT TIME ZONE requires conversion to string, use of substring and then casting to TIME/TIMESTAMP.