[fpc-devel] New functions for time zone

José Mejuto joshyfun at gmail.com
Wed Jul 11 15:57:42 CEST 2012


Hello FPC,

Wednesday, July 11, 2012, 3:09:41 PM, you wrote:

MVC> There are 2 sides to this medal. The function returns a number of timezones;
MVC> This is usually expressed as a number of hours and minutes (the OS returns
MVC> it so). The result is in 'natural' units.
MVC> Returning it as a timestamp - while useful by itself - seems rather odd.

Returning it as a timestamp is nonsense, instead return a double
representing the day fraction, so 2 hours = 2 / 86400.

MVC> I'm also not quite sure what should be returned for
MVC> negative values of the timezone info.
MVC> 'today 23:00' or "Yesterday 23:00"
MVC> I think it should remain as it is, but if you want, we can create an extra
MVC> function 'LocalTimeOffset' in DateUtils that returns the same thing as a
MVC> TDateTime. This new function can then be used in conversion routines.

Anyway the functions are nonsense as they accept a parameter for date
to be converted, and as noted in the bug report the functions must
only work over Now or NowUTC (or alike). IMHO is quite dangerous to
keep this functions as they are now in the base units, as the names
suggest that they will correctly convert any time UTC to a local time
or viceversa, so at least rename the function "GetLocalTimeOffset" to
"GetCurrentLocalTimeOffset" to note the "current" verb.

In the other hand this functions are not for local<->universal time
conversions, they displace times, calculate offsets and apply them, in
fact one function changing the sign of the offset will give the same
result as the other function.

As usual, this is just my opinion only...

-- 
Best regards,
 José




More information about the fpc-devel mailing list