I've found a bug with using 'localtime' in functions DATETIME(), DATE(), 

Platform: Windows 7.
Steps to reproduce:
1. Set your system time zone as "Russia Time Zone 2, (UTC+03:00) Moscow, 
St. Petersburg, Volgograd)".
2. Execute the following script:

SELECT DATETIME(1414267200, 'unixepoch');
SELECT DATETIME(1414267200, 'unixepoch', 'localtime');

Actual results:
2014-10-25 20:00:00
2014-10-25 23:00:00

Expected results:
2014-10-25 20:00:00
2014-10-26 00:00:00

Current local time in Moscow is "UTC+3", however it was "UTC+4" on this 

The following is the result of my own investigation, I hope this will be 
useful. sqlite uses C library function localtime(). However Microsoft's 
implementation of this function sometimes returns incorrect value. I 
sent this information to Microsoft (see 
https://connect.microsoft.com/VisualStudio/feedback/details/1984408 ), 
and they advised to use WinAPI instead of localtime_s(). As far as I can 
see, WinAPI function SystemTimeToTzSpecificLocalTime() works correctly 
for any date.

Reply via email to