* move TZSeconds to lcommon

git-svn-id: trunk@5356 -
This commit is contained in:
Almindor 2006-11-13 12:13:13 +00:00
parent ddbbcb875e
commit 6d34a8a864
3 changed files with 29 additions and 40 deletions

View File

@ -93,11 +93,13 @@ type
function IsBlockError(const anError: Integer): Boolean; inline;
function TZSeconds: Integer; inline;
function StrToHostAddr(const IP: string): Cardinal; inline;
function HostAddrToStr(const Entry: Cardinal): string; inline;
function StrToNetAddr(const IP: string): Cardinal; inline;
function NetAddrToStr(const Entry: Cardinal): string; inline;
implementation
{$IFNDEF UNIX}
@ -131,6 +133,17 @@ begin
Result:=Tmp;
end;
function TZSeconds: integer; inline;
var
lInfo: Windows.TIME_ZONE_INFORMATION;
begin
{ lInfo.Bias is in minutes }
if Windows.GetTimeZoneInformation(@lInfo) <> $FFFFFFFF then
Result := lInfo.Bias * 60
else
Result := 0;
end;
{$ELSE}
function LStrError(const Ernum: Longint; const UseUTF8: Boolean = False): string;
@ -138,6 +151,11 @@ begin
Result:=IntToStr(Ernum); // TODO: fix for non-windows winsock users
end;
function TZSeconds: integer; inline;
begin
Result:=0; // todo: fix for non-windows non unix
end;
{$ENDIF}
function LSocketError: Longint;
@ -220,7 +238,7 @@ end;
{$ELSE}
// unix
uses
Errors;
Errors, UnixUtil;
function LStrError(const Ernum: Longint; const UseUTF8: Boolean = False): string;
begin
@ -282,6 +300,11 @@ begin
Result:=(anError = ESysEWOULDBLOCK) or (anError = ESysENOBUFS);
end;
function TZSeconds: Integer; inline;
begin
Result := unixutil.TZSeconds;
end;
{$ENDIF}
function StrToHostAddr(const IP: string): Cardinal; inline;

View File

@ -477,6 +477,9 @@ type
implementation
uses
lCommon;
const
RequestBufferSize = 1024;
DataBufferSize = 16*1024;

View File

@ -30,9 +30,6 @@ interface
uses
sysutils,
{$ifdef UNIX}
unixutil,
{$endif}
strutils;
const
@ -43,7 +40,6 @@ const
type
PSearchRec = ^TSearchRec;
function TZSeconds: integer;
function GMTToLocalTime(ADateTime: TDateTime): TDateTime;
function LocalTimeToGMT(ADateTime: TDateTime): TDateTime;
function TryHTTPDateStrToDateTime(ADateStr: pchar; var ADest: TDateTime): boolean;
@ -57,41 +53,8 @@ function HexToNum(AChar: char): byte;
implementation
{$ifdef WINDOWS}
uses
windows;
function TZSeconds: integer;
var
lInfo: Windows.TIME_ZONE_INFORMATION;
begin
{ lInfo.Bias is in minutes }
if Windows.GetTimeZoneInformation(@lInfo) <> $FFFFFFFF then
Result := lInfo.Bias * 60
else
Result := 0;
end;
{$else}
{$ifdef UNIX}
function TZSeconds: integer; inline;
begin
Result := unixutil.TZSeconds;
end;
{$else}
function TZSeconds: integer; inline;
begin
Result := 0; // TODO: implement for non windows, non unix
end;
{$endif}
{$endif}
lCommon;
function GMTToLocalTime(ADateTime: TDateTime): TDateTime;
begin