mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-03 00:10:51 +02:00
+ Now time zone also works on SuSE and RedHat
This commit is contained in:
parent
d3006fcd99
commit
b3f5bf1766
@ -224,23 +224,39 @@ begin
|
|||||||
fdclose(f);
|
fdclose(f);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Const
|
||||||
|
// Debian system; contains location of timezone file.
|
||||||
|
TimeZoneLocationFile = '/etc/timezone';
|
||||||
|
// SuSE has link in /usr/lib/zoneinfo/localtime to /etc/localtime
|
||||||
|
// RedHat uses /etc/localtime
|
||||||
|
TimeZoneFile = '/usr/lib/zoneinfo/localtime';
|
||||||
|
AltTimeZoneFile = '/etc/localtime';
|
||||||
|
|
||||||
function GetTimezoneFile:string;
|
function GetTimezoneFile:string;
|
||||||
var
|
var
|
||||||
f,len : longint;
|
f,len : longint;
|
||||||
s : string;
|
s : string;
|
||||||
|
info : stat;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
GetTimezoneFile:='';
|
GetTimezoneFile:='';
|
||||||
f:=fdopen('/etc/timezone',Open_RdOnly);
|
f:=fdopen(TimeZoneLocationFile,Open_RdOnly);
|
||||||
if f=0 then
|
if f>0 then
|
||||||
exit;
|
begin
|
||||||
len:=fdread(f,s[1],high(s));
|
len:=fdread(f,s[1],high(s));
|
||||||
s[0]:=chr(len);
|
s[0]:=chr(len);
|
||||||
len:=pos(#10,s);
|
len:=pos(#10,s);
|
||||||
if len<>0 then
|
if len<>0 then
|
||||||
s[0]:=chr(len-1);
|
s[0]:=chr(len-1);
|
||||||
fdclose(f);
|
fdclose(f);
|
||||||
GetTimezoneFile:=s;
|
GetTimezoneFile:=s;
|
||||||
|
end
|
||||||
|
// Try SuSE
|
||||||
|
else if fstat(TimeZoneFile,info) then
|
||||||
|
GetTimeZoneFile:=TimeZoneFile
|
||||||
|
// Try RedHat
|
||||||
|
else If fstat(AltTimeZoneFile,Info) then
|
||||||
|
GetTimeZoneFile:=AltTimeZoneFile;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -270,7 +286,10 @@ end;
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.2 1999-12-02 11:25:31 peter
|
Revision 1.3 1999-12-04 13:50:43 michael
|
||||||
|
+ Now time zone also works on SuSE and RedHat
|
||||||
|
|
||||||
|
Revision 1.2 1999/12/02 11:25:31 peter
|
||||||
* timezone.inc dep for linux.ppu
|
* timezone.inc dep for linux.ppu
|
||||||
* fixed sigsegvs with wrong timezone settigns
|
* fixed sigsegvs with wrong timezone settigns
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user