Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix time "shift" with time zone by converting it to UTC in CAST FORMAT #2388 #7835

Merged

Conversation

TreeHunter9
Copy link
Contributor

No description provided.

Also return an exception that was "lost" in previous commits
@asfernandes
Copy link
Member

There seems to still have incorrect cases:

SQL> select cast('2023-11-03 12:00 -04:00' as timestamp format 'YYYY-MM-DD HH24:MI TZH:TZM' ) from rdb$database;

                     CAST 
========================= 
2023-11-03 12:00:00.0000  

SQL> select cast('2023-11-03 12:00 -06:00' as timestamp format 'YYYY-MM-DD HH24:MI TZH:TZM' ) from rdb$database;

                     CAST 
========================= 
2023-11-03 12:00:00.0000  
SQL> select cast('12 -04:00' as time without time zone format 'HH24 TZH:TZM' ) from rdb$database;

         CAST 
============= 
12:00:00.0000 

SQL> select cast('12 -06:00' as time without time zone format 'HH24 TZH:TZM' ) from rdb$database;

         CAST 
============= 
12:00:00.0000 

@TreeHunter9
Copy link
Contributor Author

TreeHunter9 commented Nov 9, 2023

I did it on purpose. I thought if we specify time without time zone, time zone will be ignored. If this is wrong behavior, I'll fix it.

A little off topic, I guess default conversion have some issues too with time zones:

SQL> SELECT CAST('12:30:15.1234 +03:30' AS TIME WITHOUT TIME ZONE) FROM RDB$DATABASE;

CAST 
============= 
12:00:15.1234

SQL> SELECT CAST('12:30:15.1234 -03:30' AS TIME WITHOUT TIME ZONE) FROM RDB$DATABASE;

CAST 
============= 
19:00:15.1234

@asfernandes
Copy link
Member

A little off topic, I guess default conversion have some issues too with time zones:

Looks correct for me. My time zone is -03:00:

SQL> SELECT CAST('12:30:15.1234 +03:30' AS TIME WITHOUT TIME ZONE) FROM RDB$DATABASE;

         CAST 
============= 
06:00:15.1234 

SQL> SELECT CAST('12:30:15.1234 -03:30' AS TIME WITHOUT TIME ZONE) FROM RDB$DATABASE;

         CAST 
============= 
13:00:15.1234 

What's your time zone?

@asfernandes
Copy link
Member

A little off topic, I guess default conversion have some issues too with time zones:

Looks like you are on +03:00? Then I'd say it's correct.

Then I'd say the script I send is not consistent with this behavior.

@TreeHunter9
Copy link
Contributor Author

Looks like you are on +03:00?

Correct.

@asfernandes
Copy link
Member

@TreeHunter9 are you going to fix the cases I mentioned in this PR?

@TreeHunter9
Copy link
Contributor Author

Yes, I am on a little vacation right now and away from my work PC.

Artyom Ivanov added 2 commits November 21, 2023 10:05
Also change behavior of "YY" and "YYY" the way it is done in the standard conversion.
@asfernandes asfernandes merged commit c7f88f1 into FirebirdSQL:master Nov 23, 2023
22 of 23 checks passed
@pavel-zotov
Copy link

It seems that 'RM' (abbreviation for Roman numbers) can not be used for cast from string to date in '<cast template>':

set heading off;
set echo on;

-- date.time to string:
select cast(current_date as varchar(50) format 'DD.RM.YYYY') from rdb$database;

-- string to date/time:
select cast('24.XI.2023' as date format 'DD.RM.YYYY') from rdb$database;

Output:

-- date.time to string:
select cast(current_date as varchar(50) format 'DD.RM.YYYY') from rdb$database;
24.XI.2023

-- string to date/time:
select cast('24.XI.2023' as date format 'DD.RM.YYYY') from rdb$database;

Statement failed, SQLSTATE = HY000
Value for RM pattern is out of range [1, 12]

@TreeHunter9 TreeHunter9 deleted the master_cast_format_fix_timezone branch September 14, 2024 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants