mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 17:49:29 +02:00
* Added implementation for Julian date computaton.
git-svn-id: trunk@9604 -
This commit is contained in:
parent
5acb3649df
commit
7c19e36595
@ -1979,20 +1979,22 @@ end;
|
||||
{$warnings off}
|
||||
Function DateTimeToJulianDate(const AValue: TDateTime): Double;
|
||||
begin
|
||||
NotYetImplemented('DateTimeToJulianDate');
|
||||
DateTimeToJulianDate := AValue - JulianEpoch;
|
||||
end;
|
||||
|
||||
|
||||
Function JulianDateToDateTime(const AValue: Double): TDateTime;
|
||||
begin
|
||||
NotYetImplemented('JulianDateToDateTime');
|
||||
JulianDateToDateTime := AValue + JulianEpoch;
|
||||
if(AValue <= 0) or (AValue >= 10000)then
|
||||
JulianDateToDateTime := NaN;
|
||||
end;
|
||||
|
||||
|
||||
Function TryJulianDateToDateTime(const AValue: Double; var ADateTime: TDateTime): Boolean;
|
||||
|
||||
begin
|
||||
NotYetImplemented('TryJulianDateToDateTime');
|
||||
ADateTime := JulianDateToDateTime(AValue);
|
||||
TryJulianDateToDateTime := ADateTime <> NaN;
|
||||
end;
|
||||
|
||||
|
||||
@ -2020,20 +2022,14 @@ end;
|
||||
---------------------------------------------------------------------}
|
||||
|
||||
Function DateTimeToUnix(const AValue: TDateTime): Int64;
|
||||
var
|
||||
Epoch:TDateTime;
|
||||
begin
|
||||
Epoch:=EncodeDateTime( 1970, 1, 1, 0, 0, 0, 0 );
|
||||
Result:=SecondsBetween( Epoch, AValue );
|
||||
Result:=SecondsBetween(UnixEpoch, AValue);
|
||||
end;
|
||||
|
||||
|
||||
Function UnixToDateTime(const AValue: Int64): TDateTime;
|
||||
var
|
||||
Epoch:TDateTime;
|
||||
begin
|
||||
Epoch:=EncodeDateTime( 1970, 1, 1, 0, 0, 0, 0 );
|
||||
Result:=IncSecond( Epoch, AValue );
|
||||
Result:=IncSecond(UnixEpoch, AValue);
|
||||
end;
|
||||
|
||||
|
||||
|
@ -34,8 +34,14 @@ const
|
||||
SecsPerDay = MinsPerDay * SecsPerMin;
|
||||
MSecsPerDay = SecsPerDay * MSecsPerSec;
|
||||
|
||||
{TDateTime holds the date as the number of days since 30 Dec 1899, known as
|
||||
Microsoft Excel epoch}
|
||||
JulianEpoch = TDateTime(-2415018.5);
|
||||
UnixEpoch = JulianEpoch + TDateTime(2440587.5);
|
||||
|
||||
DateDelta = 693594; // Days between 1/1/0001 and 12/31/1899
|
||||
UnixDateDelta = 25569;
|
||||
UnixDateDelta = Trunc(UnixEpoch); //25569
|
||||
|
||||
|
||||
{ True=Leapyear }
|
||||
MonthDays: array [Boolean] of TDayTable =
|
||||
|
Loading…
Reference in New Issue
Block a user