From 6e4906ff87986b78bfe52ef4d4e754a4e2359887 Mon Sep 17 00:00:00 2001 From: michael Date: Thu, 12 Jul 2001 07:20:05 +0000 Subject: [PATCH] + Added setdate/time/datetime functions --- rtl/unix/dos.pp | 9 ++++++--- rtl/unix/linux.pp | 51 ++++++++++++++++++++++++++++++++++++++++++++++- rtl/unix/unix.pp | 49 ++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 104 insertions(+), 5 deletions(-) diff --git a/rtl/unix/dos.pp b/rtl/unix/dos.pp index d3414f6f0e..0c8fd160b2 100644 --- a/rtl/unix/dos.pp +++ b/rtl/unix/dos.pp @@ -258,7 +258,7 @@ end; Procedure SetDate(Year, Month, Day: Word); Begin - {!!} + Linux.SetDate ( Year, Month, Day ); End; @@ -272,7 +272,7 @@ end; Procedure SetTime(Hour, Minute, Second, Sec100: Word); Begin - {!!} + Linux.SetTime ( Hour, Minute, Second ); End; @@ -877,7 +877,10 @@ End. { $Log$ - Revision 1.6 2001-06-03 20:19:09 peter + Revision 1.7 2001-07-12 07:20:05 michael + + Added setdate/time/datetime functions + + Revision 1.6 2001/06/03 20:19:09 peter * FSStat to StatFS * StatFS structure to TStatFS diff --git a/rtl/unix/linux.pp b/rtl/unix/linux.pp index becd36cbb8..a4271284c2 100644 --- a/rtl/unix/linux.pp +++ b/rtl/unix/linux.pp @@ -211,6 +211,9 @@ procedure GetTime(var hour,min,sec,sec100:word); procedure GetTime(var hour,min,sec:word); Procedure GetDate(Var Year,Month,Day:Word); Procedure GetDateTime(Var Year,Month,Day,hour,minute,second:Word); +function SetTime(Hour,Min,Sec:word) : Boolean; +function SetDate(Year,Month,Day:Word) : Boolean; +function SetDateTime(Year,Month,Day,hour,minute,second:Word) : Boolean; {************************** Process Handling @@ -871,6 +874,49 @@ Begin EpochToLocal(GetTimeOfDay,year,month,day,hour,minute,second); End; +{$ifdef linux} +Function stime (t : longint) : Boolean; +var + sr : Syscallregs; +begin + sr.reg2:=longint(@t); + SysCall(Syscall_nr_stime,sr); + linuxerror:=errno; + stime:=linuxerror=0; +end; +{$endif} + +{$ifdef BSD} +Function stime (t : longint) : Boolean; +begin +end; +{$endif} + +Function SetTime(Hour,Min,Sec:word) : boolean; +var + Year, Month, Day : Word; +begin + GetDate (Year, Month, Day); + SetTime:=stime ( LocalToEpoch ( Year, Month, Day, Hour, Min, Sec ) ); +end; + +Function SetDate(Year,Month,Day:Word) : boolean; +var + Hour, Minute, Second, Sec100 : Word; +begin + GetTime ( Hour, Minute, Second, Sec100 ); + SetDate:=stime ( LocalToEpoch ( Year, Month, Day, Hour, Minute, Second ) ); +end; + +Function SetDateTime(Year,Month,Day,hour,minute,second:Word) : Boolean; + +begin + SetDateTime:=stime ( LocalToEpoch ( Year, Month, Day, Hour, Minute, Second ) ); +end; + + + + { Include timezone handling routines which use /usr/share/timezone info } {$i timezone.inc} @@ -2890,7 +2936,10 @@ End. { $Log$ - Revision 1.11 2001-07-10 18:04:37 peter + Revision 1.12 2001-07-12 07:20:05 michael + + Added setdate/time/datetime functions + + Revision 1.11 2001/07/10 18:04:37 peter * merged textfile, readlink and concat ansistring fixes Revision 1.10 2001/06/03 20:19:09 peter diff --git a/rtl/unix/unix.pp b/rtl/unix/unix.pp index e879885e9e..bfaf95c79e 100644 --- a/rtl/unix/unix.pp +++ b/rtl/unix/unix.pp @@ -211,6 +211,10 @@ procedure GetTime(var hour,min,sec,sec100:word); procedure GetTime(var hour,min,sec:word); Procedure GetDate(Var Year,Month,Day:Word); Procedure GetDateTime(Var Year,Month,Day,hour,minute,second:Word); +function SetTime(Hour,Min,Sec:word) : Boolean; +function SetDate(Year,Month,Day:Word) : Boolean; +function SetDateTime(Year,Month,Day,hour,minute,second:Word) : Boolean; + {************************** Process Handling @@ -871,6 +875,46 @@ Begin EpochToLocal(GetTimeOfDay,year,month,day,hour,minute,second); End; +{$ifdef linux} +Function stime (t : longint) : Boolean; +var + sr : Syscallregs; +begin + sr.reg2:=longint(@t); + SysCall(Syscall_nr_stime,sr); + linuxerror:=errno; + stime:=linuxerror=0; +end; +{$endif} + +{$ifdef BSD} +Function stime (t : longint) : Boolean; +begin +end; +{$endif} + +Function SetTime(Hour,Min,Sec:word) : boolean; +var + Year, Month, Day : Word; +begin + GetDate (Year, Month, Day); + SetTime:=stime ( LocalToEpoch ( Year, Month, Day, Hour, Min, Sec ) ); +end; + +Function SetDate(Year,Month,Day:Word) : boolean; +var + Hour, Minute, Second, Sec100 : Word; +begin + GetTime ( Hour, Minute, Second, Sec100 ); + SetDate:=stime ( LocalToEpoch ( Year, Month, Day, Hour, Minute, Second ) ); +end; + +Function SetDateTime(Year,Month,Day,hour,minute,second:Word) : Boolean; + +begin + SetDateTime:=stime ( LocalToEpoch ( Year, Month, Day, Hour, Minute, Second ) ); +end; + { Include timezone handling routines which use /usr/share/timezone info } {$i timezone.inc} @@ -2887,7 +2931,10 @@ End. { $Log$ - Revision 1.12 2001-06-20 15:24:47 marco + Revision 1.13 2001-07-12 07:20:05 michael + + Added setdate/time/datetime functions + + Revision 1.12 2001/06/20 15:24:47 marco * readlink for Unix fix. Revision 1.11 2001/06/19 17:19:50 marco