AlignedDate(Value: DateTime;
[Forward: Boolean = true;]
[ThrowException: Boolean = true]): DateTime;
AlignedDate[Value: System.DateTime;
Forward: boolean;
ThrowException: boolean]: System.DateTime;
Value. Checked date.
Forward. Calendar offset direction.
ThrowException. Indicates whether to throw exception if the verifiable date is out of limits of series dates. Available values:
True. The default value. The exception is thrown.
False. The method returns the nearest date to start or end of the series.
The AlignedDate property returns nearest valid date.
If the verifiable date is a holiday, the method returns the nearest valid date depending on value of the Forward parameter:
Forward = True. The default value. The nearest valid date forward the calendar.
Forward = False. The nearest valid date backward the calendar.
If the checked date is a working day, the method returns the checked date without changes.
This example describes custom method.
To execute the example, add links to the Ms system assemblies.
Public Function UserAlignedDate(param: IMsTimeMatrix): Variant;
Var
m : IMsTimeMatrix;
i : Integer;
IndDate: DateTime;
Begin
m := New MsTimeMatrix.Create;
For i := m.StartIndex To m.EndIndex Do
IndDate := m.IndexToDate(i);
If m.AlignedDate(IndDate) = IndDate Then
Debug.WriteLine(m.Item(i));
End If;
End For;
Return m;
End Function UserAlignedDate;
After executing the example the console window displays values of matrix series points if the nearest valid date matches the date obtained after transforming index to date.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Ms;
…
Public Function UserAlignedDate(param: IMsTimeMatrix): object;
Var
m : IMsTimeMatrix;
i : Integer;
IndDate: DateTime;
Begin
m := New MsTimeMatrix.Create();
For i := m.StartIndex To m.EndIndex Do
IndDate := m.IndexToDate(i);
If m.AlignedDate[IndDate, True, True] = IndDate Then
System.Diagnostics.Debug.WriteLine(m.Item[i]);
End If;
End For;
Return m;
End Function UserAlignedDate;
See also: