[fpc-devel] New functions for time zone

LacaK lacak at zoznam.sk
Wed Jul 11 14:30:54 CEST 2012


Hi *,
I noticed, that there was just added new functions for supporting TZ in 
rev. 21865 and 21866
Now function GetLocalTimeOffset: Integer returns offset *in minutes* and 
later in functions LocalTimeToUniversal and UniversalTimeToLocal are 
used commands to transform it to TDateTime using EncodeTime.
(f.e. EncodeTime(TZOffset div 60, TZOffset mod 60, 0, 0))

My idea is change function GetLocalTimeOffset: TDateTime to return 
TDateTime (offset in fraction of days - native FPC datetime format)
i.e. current implementation + "Result := Result / MinsPerDay"
I think, that it will be useful, because in real applications we will 
need on each usage transform minutes to use it in Datetime calculations.
(LocalDateTime := UTCDateTime - GetLocalTimeOffset;)

Then functions LocalTimeToUniversal and UniversalTimeToLocal will be 
simple addition or subtraction like:
function UniversalTimeToLocal(UT: TDateTime; TZOffset : TDateTime): 
TDateTime;
begin
   Result := UT - TZOffset;
end;

What do you think? It will simplify all.

TIA
-Laco.



More information about the fpc-devel mailing list