Class TimeManager
Interface of classes relativizing time
Inheritance
Namespace: DCR
Assembly: Engine.dll
Syntax
public class TimeManager : Object
Remarks
Graphs may mention time via either timed responses, which require follow-up actions in the future, or timed conditions, which impose a wait-period. In both cases we must add a TimeSpan to the current time of the graph.
In general, DCR applications need to be sensitive to working days, weekends, etc: A deadline of "5" will usually mean "within 5 working days". You specify exactly how to interpret that 5 by supplying a class that can add TimeSpan to DateTimeOffset, adjusting as necessary.
Implement this interface to, e.g., skip weekends. This operation is not expected to satisfy the usual arithmetic rules of addition; however, it must behave symmetrically on negative values.
Install your implementation by setting the property TimeManager.
Constructors
TimeManager()
Construct a time manager using calendar time addition in CET.
Declaration
public TimeManager()
TimeManager(TimeZoneInfo)
Declaration
public TimeManager(TimeZoneInfo timezone)
Parameters
Type | Name | Description |
---|---|---|
System.TimeZoneInfo | timezone |
Properties
TimeZone
Set the reference timezone for pinned durations
Declaration
public TimeZoneInfo TimeZone { get; set; }
Property Value
Type | Description |
---|---|
System.TimeZoneInfo | The timezone to use; default is CET |
Remarks
When the engine applies a pinned duration such as P2D @ 10:00
,
it adds 2 days to current time using
DCR.TimeManager.OffsetBy, then fixes the time to 10:00 in
the timezone specified by this property. This mechanics is necessary to
correctly handle daylight savings time.
Methods
OffsetBy(DateTimeOffset, Duration)
Add an offset to a date
Declaration
public override DateTimeOffset OffsetBy(DateTimeOffset date, Duration duration)
Parameters
Type | Name | Description |
---|---|---|
System.DateTimeOffset | date | Date to offset |
Duration | duration |
Returns
Type | Description |
---|---|
System.DateTimeOffset | Offset date, skipping weekends and holidays as necessary. |
Remarks
This method is intended to be overriden. The default implementation uses plain date arithmetic interpreted in the timezone TimeZone.