summaryrefslogtreecommitdiff
path: root/plugins/Utils.pas/datetime.pas
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Utils.pas/datetime.pas')
-rw-r--r--plugins/Utils.pas/datetime.pas58
1 files changed, 57 insertions, 1 deletions
diff --git a/plugins/Utils.pas/datetime.pas b/plugins/Utils.pas/datetime.pas
index f30d186b4e..4b13d7b3f4 100644
--- a/plugins/Utils.pas/datetime.pas
+++ b/plugins/Utils.pas/datetime.pas
@@ -18,7 +18,8 @@ function IsLeapYear(Year:word):Boolean;
function EncodeTime(Hour, Minute, Sec: cardinal):TDateTime;
function EncodeDate(Year, Month , Day: cardinal):TDateTime;
-function Timestamp(Year,Month,Day:cardinal;Hour:cardinal=0;Minute:cardinal=0;Sec:cardinal=0):dword;
+function Timestamp(Year,Month,Day:cardinal;Hour:cardinal=0;Minute:cardinal=0;Sec:cardinal=0):dword; overload;
+function Timestamp(const st:TSystemTime):dword; overload;
function GetCurrentTimestamp:DWord;
procedure UnixTimeToFileTime(ts:int_ptr; var pft:TFILETIME);
@@ -31,6 +32,10 @@ function DateTimeToStr(Time:Dword; Format:pWideChar=nil):pWideChar;
function DateToStr (Time:Dword; Format:pWideChar=nil):pWideChar;
function TimeToStr (Time:Dword; Format:pWideChar=nil):pWideChar;
+function CompareDate(const one,two:TSystemTime):integer;
+function CompareTime(const one,two:TSystemTime):integer;
+function TimeToMidnight(const t:TSystemTime):integer;
+
implementation
uses
@@ -83,6 +88,12 @@ begin
result:=Round((t - UnixDateDelta) * SecondsPerDay);
end;
+function Timestamp(const st:TSystemTime):dword;
+ {$IFDEF AllowInline}inline;{$ENDIF}
+begin
+ result:=Timestamp(st.wYear,st.wMonth,st.wDay,st.wHour,st.wMinute,st.wSecond);
+end;
+
function GetCurrentTimestamp:dword;
var
st:tSystemTime;
@@ -171,4 +182,49 @@ begin
StrDupW(result,buf);
end;
+function CompareDate(const one,two:TSystemTime):integer;
+var
+ t1,t2:integer;
+begin
+ t1:=((one.wYear*12)+one.wMonth)*32+one.wDay;
+ t2:=((two.wYear*12)+two.wMonth)*32+two.wDay;
+ result:=t1-t2;
+{
+ result:=one.wYear-two.wYear;
+ if result=0 then
+ begin
+ result:=one.wMonth-two.wMonth;
+ if result=0 then
+ begin
+ result:=one.wDay-two.wDay;
+ end;
+ end;
+}
+end;
+
+function CompareTime(const one,two:TSystemTime):integer;
+var
+ t1,t2:integer;
+begin
+ t1:=one.wHour*3600+one.wMinute*60+one.wSecond;
+ t2:=two.wHour*3600+two.wMinute*60+two.wSecond;
+ result:=t1-t2;
+{
+ result:=one.wHour-two.wHour;
+ if result=0 then
+ begin
+ result:=one.wMinute-two.wMinute;
+ if result=0 then
+ begin
+ result:=one.wSecond-two.wSecond;
+ end;
+ end;
+}
+end;
+
+function TimeToMidnight(const t:TSystemTime):integer;
+begin
+ result:=SecondsPerDay-(t.wHour*3600+t.wMinute*60+t.wSecond);
+end;
+
end.