# title: substring from timestamp - unexpected result
# decription:
# 26.01.2019. Note for 4.0.
# Made more careful parsing for each token of timestamp because of time-with-timezone introduction.
# Checed on:
# 4.0.0.1340: OK, 2.313s.
# 4.0.0.1410: OK, 2.360s.
#
# 02.02.2019. Note for 4.0.
# One need to EXPLICITLY add statement SET TIME ZONE <+HH:MM> at the beginning of test, otherwise
# we will get eception because current_timestamp string will have length more than expected.
# This is because DEFAULT time zone in FB 4.0 includes REGION NAME ('Moscow/Europe") instead of HH:MM shift.
# Checked on:
# 4.0.0.1421: OK, 1.493s.
#
#
# tracker_id: CORE-2756
# min_versions: ['2.5.1']
# versions: 4.0
# qmid: None
importpytest
fromfirebird.qaimportdb_factory,isql_act,Action
# version: 4.0
# resources: None
substitutions_1=[]
init_script_1=""""""
db_1=db_factory(sql_dialect=3,init=init_script_1)
test_script_1="""
setliston;
settimezone'+00:00';
select
--dts,
iif(left(dts,4)=extract(yearfromcurrent_timestamp),'Looks as expected','Unexpected for dts = '||dts)asyear_as_numeric
,iif(substring(dtsfrom5for1)='-','Looks as expected','Unexpected for dts = '||dts)asyear_month_separator
,iif(substring(dtsfrom6for2)=lpad(extract(monthfromcurrent_timestamp),2,'0'),'Looks as expected','Unexpected for dts = '||dts)month_as_numeric
,iif(substring(dtsfrom8for1)='-','Looks as expected','Unexpected for dts = '||dts)asmonth_day_separator
,iif(substring(dtsfrom9for2)=lpad(extract(dayfromcurrent_timestamp),2,'0'),'Looks as expected','Unexpected for dts = '||dts)day_as_numeric
,iif(substring(dtsfrom11for1)='','Looks as expected','Unexpected for dts = '||dts)asdate_time_space_separator
,iif(substring(dtsfrom12for2)=lpad(extract(hourfromcurrent_timestamp),2,'0'),'Looks as expected','Unexpected for dts = '||dts)hour_as_numeric
,iif(substring(dtsfrom14for1)=':','Looks as expected','Unexpected for dts = '||dts)astime_hours_minutes_separator
,iif(substring(dtsfrom15for2)=lpad(extract(minutefromcurrent_timestamp),2,'0'),'Looks as expected','Unexpected for dts = '||dts)minute_as_numeric
,iif(substring(dtsfrom17for1)=':','Looks as expected','Unexpected for dts = '||dts)astime_minutes_seconds_separator
,iif(substring(dtsfrom18for2)=lpad(floor(extract(secondfromcurrent_timestamp)),2,'0'),'Looks as expected','Unexpected for dts = '||dts)second_as_numeric
,iif(substring(dtsfrom20for1)='.','Looks as expected','Unexpected for dts = '||dts)astime_seconds_millis_separator
,iif(substring(dtsfrom21for4)=lpad(10*floor(extract(millisecondfromcurrent_timestamp)),4,'0'),'Looks as expected','Unexpected for dts = '||dts)millisec_as_numeric
,iif(substring(dtsfrom25for1)='','Looks as expected','Unexpected for dts = '||dts)astime_timezone_space_separator
,iif(substring(dtsfrom26for1)in('+','-'),'Looks as expected','Unexpected for dts = '||dts)GMT_shift_direction
,iif(substring(dtsfrom27for2)similarto'[[:DIGIT:]]{2}','Looks as expected','Unexpected for dts = '||dts)GMT_shift_hours
,iif(substring(dtsfrom29for1)=':','Looks as expected','Unexpected for dts = '||dts)asGMT_shift_time_separator
,iif(substring(dtsfrom30for2)similarto'[[:DIGIT:]]{2}','Looks as expected','Unexpected for dts = '||dts)GMT_shift_minutes