diff options
author | Alexey Kulakov <panda75@bk.ru> | 2014-12-31 17:08:47 +0000 |
---|---|---|
committer | Alexey Kulakov <panda75@bk.ru> | 2014-12-31 17:08:47 +0000 |
commit | da87b3fa0479333cfe9505713f6ffaa54b9ba543 (patch) | |
tree | d4868e4947c3944bb3313a057ec3b189a876018f /plugins/Utils.pas/datetime.pas | |
parent | f33f9ebac9806cba6bfd89715566a65c29b5fee2 (diff) |
pascal code: reformat, small fixes
git-svn-id: http://svn.miranda-ng.org/main/trunk@11700 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Utils.pas/datetime.pas')
-rw-r--r-- | plugins/Utils.pas/datetime.pas | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/plugins/Utils.pas/datetime.pas b/plugins/Utils.pas/datetime.pas index e2fa2e4809..99b85ee80b 100644 --- a/plugins/Utils.pas/datetime.pas +++ b/plugins/Utils.pas/datetime.pas @@ -28,14 +28,18 @@ function TimeStampToLocalTimeStamp(ts:int_ptr):int_ptr; function TimestampToDateTime(ts:int_ptr):TDateTime;
function TimestampToSystemTime(Time:DWord; var st:TSystemTime):PSystemTime;
-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 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;
-
+{
+procedure TimeToFileTime(var ft:TFILETIME;
+ Second:cardinal=0;Minute:cardinal=0;Hour:cardinal=0;Day:cardinal=0);
+procedure FileTimeToTime(const ft:TFILETIME; var Second,Minute,Hour,Day:cardinal);
+}
implementation
uses
@@ -144,11 +148,11 @@ begin result:=@st;
end;
-function DateTimeToStr(Time:Dword; Format:pWideChar=nil):pWideChar;
+function DateTimeToStr(Time:Dword; Format:PWideChar=nil):PWideChar;
var
buf:array [0..300] of WideChar;
st: TSystemTime;
- pc:pWideChar;
+ pc:PWideChar;
begin
TimestampToSystemTime(Time,st);
GetDateFormatW(LOCALE_USER_DEFAULT,0,@st,Format,@buf,300);
@@ -157,12 +161,12 @@ begin else
begin
pc:=StrEndW(@buf); pc^:=' '; inc(pc);
- GetTimeFormatW(LOCALE_USER_DEFAULT,0,@st,nil,pc,300-(pc-pWideChar(@buf)))
+ GetTimeFormatW(LOCALE_USER_DEFAULT,0,@st,nil,pc,300-(pc-PWideChar(@buf)))
end;
StrDupW(result,buf);
end;
-function DateToStr(Time:Dword; Format:pWideChar=nil):pWideChar;
+function DateToStr(Time:Dword; Format:PWideChar=nil):PWideChar;
var
buf:array [0..300] of WideChar;
st: TSystemTime;
@@ -172,7 +176,7 @@ begin StrDupW(result,buf);
end;
-function TimeToStr(Time:Dword; Format:pWideChar=nil):pWideChar;
+function TimeToStr(Time:Dword; Format:PWideChar=nil):PWideChar;
var
buf:array [0..300] of WideChar;
st: TSystemTime;
@@ -227,4 +231,27 @@ begin result:=SecondsPerDay-(t.wHour*3600+t.wMinute*60+t.wSecond);
end;
+procedure TimeToFileTime(var ft:TFILETIME;
+ Second:cardinal=0;Minute:cardinal=0;Hour:cardinal=0;Day:cardinal=0);
+var
+ uli:ULARGE_INTEGER;
+begin
+ uli.QuadPart:=int64(Second+Minute*60+Hour*60*60+Day*SecondsPerDay)*10*1000*1000;
+ ft.dwLowDateTime :=uli.LowPart;
+ ft.dwHighDateTime:=uli.HighPart;
+end;
+
+procedure FileTimeToTime(const ft:TFILETIME; var Second,Minute,Hour,Day:cardinal);
+var
+ uli:ULARGE_INTEGER;
+begin
+ uli.LowPart :=ft.dwLowDateTime;
+ uli.HighPart:=ft.dwHighDateTime;
+ uli.QuadPart:=uli.QuadPart div (10*1000*1000);
+ Second:= uli.QuadPart mod 60;
+ Day := uli.QuadPart div SecondsPerDay;
+ Minute:=(uli.QuadPart div 60) mod 60;
+ Hour :=(uli.QuadPart mod SecondsPerDay) div (60*60);
+end;
+
end.
|