[fpc-pascal] UniversalTimeToLocal(UT: TDateTime) / LocalTimeToUniversal(LT: TDateTime)

Michael Van Ham michael.vanham at gmail.com
Mon Jul 20 01:25:20 CEST 2015


Hello FreePascal developers,


I believe that since SVN commit 30628 UniversalTimeToLocal(UT: TDateTime)
and LocalTimeToUniversal(LT: TDateTime) are reporting incorrect values.

The multiple parameter versions of these functions had their offset
handling changed to a more expected format as described in bug id 24752 [1].

The single parameter versions call GetLocalTimeOffset, which ultimately
calls GetTimeZoneInformation. This function returns the 'bias', where: UTC
= local time + bias [2].

The bias needs to be inverted before being sent to the new
UniversalTimeToLocal/LocalTimeToUniversal functions.

Please consider the attached patch.


Thank you.


[1] http://mantis.freepascal.org/view.php?id=24752
[2]
https://msdn.microsoft.com/en-us/library/windows/desktop/ms724421(v=vs.85).aspx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20150719/885b0c89/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dateutil.inc.patch
Type: application/octet-stream
Size: 734 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20150719/885b0c89/attachment.obj>


More information about the fpc-pascal mailing list