DateToIndex(Value: DateTime): Integer;
DateToIndex(Value: System.DateTime): integer;
Value. Calendar series point.
The DateToIndex method transforms date to index.
To transform index to date, use the IMsTimeMatrix.IndexToDate method.
This example describes custom method.
To execute the example, add links to the MS, MathFin system assemblies.
Public Function Max(Matrix: IMsTimeMatrix): Variant;
Var
Serie : ITimeSeries;
index, i : integer;
arr : Array Of double;
Begin
Serie := New TimeSeries.Create;
index := Matrix.CurrentIndex;
If Matrix.DateToIndex(Matrix.ForecastStartDate) <> index Then
For i := 0 To Matrix.PointCount - 1 Do
arr := Matrix.Column(i) As Array Of double;
Serie.Item(i) := Math.Max(arr);
End For;
End If;
Return Serie;
End Function Max;
The method finds maximum value in matrix series points if the value obtained on transformation of date into index does not match the current calculation index.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.MathFin;
…
Public Function Max1(Matrix: IMsTimeMatrix): object;
Var
Serie : ITimeSeries;
index, i : integer;
arr : Array Of double;
Math: MathClass = New MathClass();
Begin
Serie := New TimeSeries.Create();
index := Matrix.CurrentIndex;
If Matrix.DateToIndex(Matrix.ForecastStartDate) <> index Then
For i := 0 To Matrix.PointCount - 1 Do
arr := Matrix.Column(i) As Array Of double;
Serie.Item[i] := Math.Max(arr);
End For;
End If;
Return Serie;
End Function Max1;
See also: