UniversalTimeToLocal applies minutes offset in the wrong direction from UTC
Original Reporter info from Mantis: tedsmith
-
Reporter name: TED SMITH
Original Reporter info from Mantis: tedsmith
- Reporter name: TED SMITH
Description:
UniversalTimeToLocal takes the time offset in the wrong direction from UTC. The expected behaviour for UTC offsets is "+X" minutes forward from UTC or "-X" minutes back from UTC. UniversalTimeToLocal does the opposite; if the user supplies a desired offset of "+120" minutes, the time is taken back two hours from UTC, instead of forward, and visa versa for negative offsets.
(UniversalTimeToLocal(DateOfAction, TimeZoneOffset))
This refers: http://forum.lazarus.freepascal.org/index.php/topic,20831.msg126002.html#msg126002
A supplied demo is attached.
Steps to reproduce:
Using Lazarus 1.0.8, FPC 2.62, dated 17/03/13, SVN ver 40573....
Create a form with an edit box, a button and some labels.
Accept an offset value of either XXXX or -XXXX via the edit.text property.
Cast a variable (called 'TimeZoneOffset) as an integer to store the integer value of the offset
Convert the inputted text offset as an integer using TimeZoneOffset := StrToInt(edit1.text); // negative values are converted accordingly by StrToInt
[code]
TheDateTime := Now; \ (or any date value)
strCreatedDate := DateTimeToStr(UniversalTimeToLocal(TheDateTime, TimeZoneOffset));
[/code]
If the user provides "120" as input, and if TheDateTime is equal to 01/01/12 15:15, strCreatedDate becomes
"01/01/12 13:15" (back two hours) instead of
"01/01/12 17:15" (forward two hours)
If the user provides "-120" as input, and if TheDateTime is equal to 01/01/12 15:15, strCreatedDate becomes
"01/01/12 17:15" (forward two hours) instead of
"01/01/12 13:15" (back two hours)
Mantis conversion info:
- Mantis ID: 24752
- Build: Lazarus 1.0.8, FPC 2.6.2
- Version: 2.6.2
- Fixed in version: 3.0.0
- Fixed in revision: 30628 (#f9f602dc)
- Target version: 3.0.0