Browse Source

* Added GetLocalTimeOffset function

git-svn-id: trunk@21865 -
michael 13 years ago
parent
commit
64ab9c06d3
4 changed files with 35 additions and 2 deletions
  1. 7 0
      rtl/objpas/sysutils/dati.inc
  2. 1 0
      rtl/objpas/sysutils/datih.inc
  3. 7 1
      rtl/unix/sysutils.pp
  4. 20 1
      rtl/win/sysutils.pp

+ 7 - 0
rtl/objpas/sysutils/dati.inc

@@ -1394,3 +1394,10 @@ begin
   DateTime:=tmp;
   DateTime:=tmp;
 end;
 end;
 
 
+{$IFNDEF HAS_LOCALTIMEZONEOFFSET}
+Function GetLocalTimeOffset : Integer;
+
+begin
+  Result:=0;
+end;
+{$ENDIF}

+ 1 - 0
rtl/objpas/sysutils/datih.inc

@@ -186,3 +186,4 @@ Procedure GetLocalTime(var SystemTime: TSystemTime);
 
 
 procedure ReplaceTime(var dati:TDateTime; NewTime : TDateTime); inline;
 procedure ReplaceTime(var dati:TDateTime; NewTime : TDateTime); inline;
 procedure ReplaceDate(var DateTime: TDateTime; const NewDate: TDateTime); inline;
 procedure ReplaceDate(var DateTime: TDateTime; const NewDate: TDateTime); inline;
+function GetLocalTimeOffset: Integer;

+ 7 - 1
rtl/unix/sysutils.pp

@@ -33,7 +33,7 @@ interface
 {$DEFINE HASUNIX}
 {$DEFINE HASUNIX}
 {$DEFINE HASCREATEGUID}
 {$DEFINE HASCREATEGUID}
 {$DEFINE HAS_OSUSERDIR}
 {$DEFINE HAS_OSUSERDIR}
-
+{$DEFINE HAS_LOCALTIMEZONEOFFSET}
 uses
 uses
   Unix,errors,sysconst,Unixtype;
   Unix,errors,sysconst,Unixtype;
 
 
@@ -1401,6 +1401,12 @@ begin
   Flush(Output);
   Flush(Output);
 end;
 end;
 
 
+function GetLocalTimeOffset: Integer;
+
+begin
+ Result := -Tzseconds div 60; 
+end;
+
 {****************************************************************************
 {****************************************************************************
                               Initialization code
                               Initialization code
 ****************************************************************************}
 ****************************************************************************}

+ 20 - 1
rtl/win/sysutils.pp

@@ -30,7 +30,7 @@ uses
 {$DEFINE HAS_OSCONFIG}
 {$DEFINE HAS_OSCONFIG}
 {$DEFINE HAS_OSUSERDIR}
 {$DEFINE HAS_OSUSERDIR}
 {$DEFINE HAS_CREATEGUID}
 {$DEFINE HAS_CREATEGUID}
-
+{$DEFINE HAS_LOCALTIMEZONEOFFSET}
 { Include platform independent interface part }
 { Include platform independent interface part }
 {$i sysutilh.inc}
 {$i sysutilh.inc}
 
 
@@ -587,6 +587,25 @@ begin
   windows.Getlocaltime(SystemTime);
   windows.Getlocaltime(SystemTime);
 end;
 end;
 
 
+function GetLocalTimeOffset: Integer;
+
+var 
+  TZInfo: TTimeZoneInformation;
+
+begin
+   case GetTimeZoneInformation(TZInfo) of
+     TIME_ZONE_ID_UNKNOWN:
+       Result := TZInfo.Bias;
+     TIME_ZONE_ID_STANDARD:
+       Result := TZInfo.Bias + TZInfo.StandardBias;
+     TIME_ZONE_ID_DAYLIGHT:
+       Result := TZInfo.Bias + TZInfo.DaylightBias;
+     else
+       Result := 0;
+   end;
+end; 
+ 
+                                                                    
 
 
 {****************************************************************************
 {****************************************************************************
                               Misc Functions
                               Misc Functions