AlignedDate(Value: DateTime; [Forward: Boolean = True;] [ThrowException: Boolean = True]): DateTime;
Value. Checked date.
Forward. Calendar offset direction. Optional parameter.
ThrowException. Indicates whether to generate the exception if the checked date is out of limits of series dates. Optional parameter. 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 checked date is a day off, 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 shows the user calculation method for a series with daily frequency. To execute the example, add links to the Ms, Transform system assemblies.
Function UserAlignedDate(Input: ITimeSeries): ITimeSeries;
Var
pContext: ITsCalculationContext;
i: Integer;
pSeries: ITimeSeries;
Begin
pContext := TsCalculation.Current;
pSeries := pContext.CreateTimeSeries;
For i := Input.StartIndex To Input.EndIndex Do
If Input.AlignedDate(Input.IndexToDate(i)) = Input.IndexToDate(i) Then
pSeries.Item(i) := 1 + Input.Item(i);
End If;
End For;
Return pSeries;
End Function UserAlignedDate;
The method increases series values that correspond to working days.
See also: