DateTimeOffsetExtensions Class
Provides extension methods for System.DateTimeOffset to support interval-based add, substract and alignment operations.
public static class DateTimeOffsetExtensionsInheritance System.Object 🡒 DateTimeOffsetExtensions
Methods
Section titled “Methods”DateTimeOffsetExtensions.AddInterval(this DateTimeOffset, IInterval, ITimeZone, IIntervalFactory) Method
Section titled “DateTimeOffsetExtensions.AddInterval(this DateTimeOffset, IInterval, ITimeZone, IIntervalFactory) Method”Adds a given IInterval to the specified System.DateTimeOffsetstartTime while taking into account the rules of the provided ITimeZone. This ensures that daylight saving time changes are correctly handled.
public static System.DateTimeOffset AddInterval(this System.DateTimeOffset startTime, HAKOM.TSM.Net.Api.Time.Intervals.IInterval interval, HAKOM.TSM.Net.Api.Time.TimeZones.ITimeZone timeZone, HAKOM.TSM.Net.Api.Time.Intervals.IIntervalFactory intervalFactory);Parameters
Section titled “Parameters”startTime System.DateTimeOffset
The point in time to which the interval will be added.
interval IInterval
The IInterval representing the duration to apply.
timeZone ITimeZone
The ITimeZone that provides context for how the interval should be applied, especially around ambiguous or invalid times due to daylight saving.
intervalFactory IIntervalFactory
The IIntervalFactory used internally to construct adjusted intervals when needed for complex time shifting logic.
Returns
Section titled “Returns”System.DateTimeOffset
A System.DateTimeOffset representing the new point in time after applying the interval in the given time zone context.
DateTimeOffsetExtensions.AlignWithNext(this DateTimeOffset, IInterval, ITimeZone, DateTimeOffset, IIntervalFactory, ITimeSeriesDataFactory) Method
Section titled “DateTimeOffsetExtensions.AlignWithNext(this DateTimeOffset, IInterval, ITimeZone, DateTimeOffset, IIntervalFactory, ITimeSeriesDataFactory) Method”Aligns the specified givenDate to the next upcoming occurrence on the interval grid, starting from the defined startOfTime. The alignment respects the rules of the given ITimeZone and uses the specified IInterval to determine the spacing between grid points.
public static System.DateTimeOffset AlignWithNext(this System.DateTimeOffset givenDate, HAKOM.TSM.Net.Api.Time.Intervals.IInterval interval, HAKOM.TSM.Net.Api.Time.TimeZones.ITimeZone timeZone, System.DateTimeOffset startOfTime, HAKOM.TSM.Net.Api.Time.Intervals.IIntervalFactory intervalFactory, HAKOM.TSM.Net.Api.Data.TimeSeries.ITimeSeriesDataFactory timeSeriesDataFactory);Parameters
Section titled “Parameters”givenDate System.DateTimeOffset
The System.DateTimeOffset to align. This is the target timestamp that will be shifted forward to the next aligned point on the interval grid.
interval IInterval
The IInterval that defines the step size inbetween points on the grid and is used for alignment.
timeZone ITimeZone
The ITimeZone that provides context for how the interval should be applied, especially around ambiguous or invalid times due to daylight saving.
startOfTime System.DateTimeOffset
The anchor point or origin of the interval grid. All aligned times are computed relative to this point, following multiples of interval from this origin.
intervalFactory IIntervalFactory
The IIntervalFactory used internally to construct adjusted intervals when needed for complex time shifting logic.
timeSeriesDataFactory ITimeSeriesDataFactory
The ITimeSeriesDataFactory used when needed for complex time shifting logic.
Returns
Section titled “Returns”System.DateTimeOffset
A System.DateTimeOffset representing the earliest aligned time that is greater than or equal to
givenDate, computed from the interval grid originating at startOfTime.
Exceptions
Section titled “Exceptions”StartOfTimeIsAfterGivenDateException
Thrown when startOfTime is after givenDate and thus no alignment is possible.
System.NotSupportedException
Thrown when the specified interval is not supported by the alignment logic.
DateTimeOffsetExtensions.AlignWithPrevious(this DateTimeOffset, IInterval, ITimeZone, DateTimeOffset, IIntervalFactory, ITimeSeriesDataFactory) Method
Section titled “DateTimeOffsetExtensions.AlignWithPrevious(this DateTimeOffset, IInterval, ITimeZone, DateTimeOffset, IIntervalFactory, ITimeSeriesDataFactory) Method”Aligns the specified givenDate to the most recent previous occurrence on the interval grid, starting from the defined startOfTime. The alignment respects the rules of the given ITimeZone and uses the specified IInterval for spacing between points.
public static System.DateTimeOffset AlignWithPrevious(this System.DateTimeOffset givenDate, HAKOM.TSM.Net.Api.Time.Intervals.IInterval interval, HAKOM.TSM.Net.Api.Time.TimeZones.ITimeZone timeZone, System.DateTimeOffset startOfTime, HAKOM.TSM.Net.Api.Time.Intervals.IIntervalFactory intervalFactory, HAKOM.TSM.Net.Api.Data.TimeSeries.ITimeSeriesDataFactory timeSeriesDataFactory);Parameters
Section titled “Parameters”givenDate System.DateTimeOffset
The System.DateTimeOffset to align. This is the target timestamp that will be shifted backwards to the nearest aligned point on the interval grid.
interval IInterval
The IInterval that defines the step size inbetween points on the grid and is used for alignment.
timeZone ITimeZone
The ITimeZone that provides context for how the interval should be applied, especially around ambiguous or invalid times due to daylight saving.
startOfTime System.DateTimeOffset
The anchor point or origin of the interval grid. All aligned times are computed relative to this point, following multiples of interval from this origin.
intervalFactory IIntervalFactory
The IIntervalFactory used internally to construct adjusted intervals when needed for complex time shifting logic.
timeSeriesDataFactory ITimeSeriesDataFactory
The ITimeSeriesDataFactory used when needed for complex time shifting logic.
Returns
Section titled “Returns”System.DateTimeOffset
A System.DateTimeOffset representing the latest aligned time that is less than or equal to
givenDate, computed from the interval grid originating at startOfTime.
Exceptions
Section titled “Exceptions”StartOfTimeIsAfterGivenDateException
Thrown when startOfTime is after givenDate and thus no alignment is possible.
System.NotSupportedException
Thrown when the specified interval is not supported by the alignment logic.
DateTimeOffsetExtensions.FromHakomTime(long, TimeBase) Method
Section titled “DateTimeOffsetExtensions.FromHakomTime(long, TimeBase) Method”Converts a Hakom time representation to a System.DateTimeOffset based on the specified TimeBase.
public static System.DateTimeOffset FromHakomTime(long hakomTime, HAKOM.TSM.Net.Api.Time.TimeBases.TimeBase timeBase);Parameters
Section titled “Parameters”hakomTime System.Int64
The Hakom time value to convert.
timeBase TimeBase
The TimeBase that determines the interpretation of the hakomTime value.
Returns
Section titled “Returns”System.DateTimeOffset
A System.DateTimeOffset representing the converted time.
Remarks
Section titled “Remarks”- UnixSecond(): Interprets the value as Unix time in seconds (epoch: 1970-01-01 00:00:00 UTC)
- UnixMillisecond(): Interprets the value as Unix time in milliseconds (epoch: 1970-01-01 00:00:00.000 UTC)
- HakomSecond() or default: Interprets the value as Hakom seconds with an offset (epoch: 1972-01-01 00:00:00 UTC+1)
DateTimeOffsetExtensions.SubtractInterval(this DateTimeOffset, IInterval, ITimeZone, IIntervalFactory) Method
Section titled “DateTimeOffsetExtensions.SubtractInterval(this DateTimeOffset, IInterval, ITimeZone, IIntervalFactory) Method”Subtracts a given IInterval to the specified System.DateTimeOffsetstartTime while taking into account the rules of the provided ITimeZone. This ensures that daylight saving time changes are correctly handled.
public static System.DateTimeOffset SubtractInterval(this System.DateTimeOffset startTime, HAKOM.TSM.Net.Api.Time.Intervals.IInterval interval, HAKOM.TSM.Net.Api.Time.TimeZones.ITimeZone timeZone, HAKOM.TSM.Net.Api.Time.Intervals.IIntervalFactory intervalFactory);Parameters
Section titled “Parameters”startTime System.DateTimeOffset
The point in time to which the interval will be subtracted.
interval IInterval
The IInterval representing the duration to apply.
timeZone ITimeZone
The ITimeZone that provides context for how the interval should be applied, especially around ambiguous or invalid times due to daylight saving.
intervalFactory IIntervalFactory
The IIntervalFactory used internally to construct adjusted intervals when needed for complex time shifting logic.
Returns
Section titled “Returns”System.DateTimeOffset
A System.DateTimeOffset representing the new point in time after applying the interval in the given time zone context.
DateTimeOffsetExtensions.ToHakomTime(this DateTimeOffset, TimeBase) Method
Section titled “DateTimeOffsetExtensions.ToHakomTime(this DateTimeOffset, TimeBase) Method”Converts a System.DateTimeOffset to Hakom time representation based on the specified TimeBase.
public static long ToHakomTime(this System.DateTimeOffset dateTimeOffset, HAKOM.TSM.Net.Api.Time.TimeBases.TimeBase timeBase);Parameters
Section titled “Parameters”dateTimeOffset System.DateTimeOffset
The System.DateTimeOffset to convert.
timeBase TimeBase
The TimeBase that determines the conversion format.
Returns
Section titled “Returns”System.Int64
A System.Int64 representing the time in the specified Hakom time format.
Remarks
Section titled “Remarks”- UnixSecond(): Converts to Unix time in seconds (epoch: 1970-01-01 00:00:00 UTC)
- UnixMillisecond(): Converts to Unix time in milliseconds (epoch: 1970-01-01 00:00:00.000 UTC)
- HakomSecond() or default: Converts to Hakom seconds with an offset (epoch: 1972-01-01 00:00:00 UTC+1)