mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 11:29:18 +02:00
* fixed MSecsToTimeStamp by Lagunov Aleksey, resolves #38631
git-svn-id: trunk@49247 -
This commit is contained in:
parent
43c50d0a32
commit
dbee3bcc0d
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -18820,6 +18820,7 @@ tests/webtbs/tw38549c.pp svneol=native#text/plain
|
|||||||
tests/webtbs/tw38549d.pp svneol=native#text/plain
|
tests/webtbs/tw38549d.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw38557.pp svneol=native#text/pascal
|
tests/webtbs/tw38557.pp svneol=native#text/pascal
|
||||||
tests/webtbs/tw3863.pp svneol=native#text/plain
|
tests/webtbs/tw3863.pp svneol=native#text/plain
|
||||||
|
tests/webtbs/tw38631.pp svneol=native#text/pascal
|
||||||
tests/webtbs/tw38636.pp svneol=native#text/plain
|
tests/webtbs/tw38636.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw3864.pp svneol=native#text/plain
|
tests/webtbs/tw3864.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw38642.pp svneol=native#text/pascal
|
tests/webtbs/tw38642.pp svneol=native#text/pascal
|
||||||
|
@ -75,18 +75,20 @@ end;
|
|||||||
{ MSecsToTimeStamp }
|
{ MSecsToTimeStamp }
|
||||||
|
|
||||||
function MSecsToTimeStamp(MSecs: comp): TTimeStamp;
|
function MSecsToTimeStamp(MSecs: comp): TTimeStamp;
|
||||||
|
var
|
||||||
|
D1:Int64;
|
||||||
begin
|
begin
|
||||||
result.Date := Trunc(msecs / msecsperday);
|
D1:=Trunc(msecs);
|
||||||
msecs:= msecs-comp(result.date)*msecsperday;
|
result.Date := D1 div msecsperday;
|
||||||
result.Time := Round(MSecs);
|
result.Time := D1 - result.date * msecsperday;
|
||||||
end ;
|
end;
|
||||||
|
|
||||||
{ TimeStampToMSecs }
|
{ TimeStampToMSecs }
|
||||||
|
|
||||||
function TimeStampToMSecs(const TimeStamp: TTimeStamp): comp;
|
function TimeStampToMSecs(const TimeStamp: TTimeStamp): comp;
|
||||||
begin
|
begin
|
||||||
result := TimeStamp.Time + comp(timestamp.date)*msecsperday;
|
result := TimeStamp.Time + comp(timestamp.date)*msecsperday;
|
||||||
end ;
|
end;
|
||||||
|
|
||||||
Function TryEncodeDate(Year,Month,Day : Word; Out Date : TDateTime) : Boolean;
|
Function TryEncodeDate(Year,Month,Day : Word; Out Date : TDateTime) : Boolean;
|
||||||
|
|
||||||
|
23
tests/webtbs/tw38631.pp
Normal file
23
tests/webtbs/tw38631.pp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{$mode objfpc}
|
||||||
|
program msec_test1;
|
||||||
|
uses sysutils;
|
||||||
|
|
||||||
|
var
|
||||||
|
D: TDateTime;
|
||||||
|
T, T1, T2: TTimeStamp;
|
||||||
|
MS: Comp;
|
||||||
|
begin
|
||||||
|
D:=EncodeDate(2021, 03, 16) + EncodeTime(14, 02, 15, 1);
|
||||||
|
WriteLn('DATE: ', DateTimeToStr(D));
|
||||||
|
|
||||||
|
T:=DateTimeToTimeStamp(D);
|
||||||
|
WriteLn(' T.Date=',T.Date,' T.Time=', T.Time);
|
||||||
|
MS:=TimeStampToMSecs(T);
|
||||||
|
T1:=MSecsToTimeStamp(MS);
|
||||||
|
WriteLn('T1.Date=',T1.Date,' T1.Time=', T1.Time);
|
||||||
|
|
||||||
|
WriteLn('DATE1: ', DateTimeToStr(TimeStampToDateTime(T1)));
|
||||||
|
if TimeStampToDateTime(T1)<>D then
|
||||||
|
halt(1);
|
||||||
|
writeln('ok')
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user