[fpc-devel] New functions for time zone

Michael Van Canneyt michael at freepascal.org
Wed Jul 11 16:38:19 CEST 2012



On Wed, 11 Jul 2012, José Mejuto wrote:

> 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.

Not if they have the TZOffset parameter as well.

Without this information they are indeed nonsense. 
That is why I added the parameter.

If someone does not supply it, the current one will be taken; 
it is simply meant for current time operations.

The behaviour will be documented, and there will be a remark about the TZ info being time dependent.
If someone doesn't know what he is doing, that's his problem.

Michael.


More information about the fpc-devel mailing list