Class DateTimeDecoratorExtensions
- Namespace
- Cuemon
- Assembly
- Cuemon.Core.dll
Extension methods for the System.DateTime struct hidden behind the IDecorator<T> interface.
public static class DateTimeDecoratorExtensions
- Inheritance
-
ObjectDateTimeDecoratorExtensions
Methods
GetUnixEpoch(IDecorator<DateTime>)
Gets a System.DateTime initialized to midnight, January 1st, 1970 in Coordinated Universal Time (UTC).
public static DateTime GetUnixEpoch(this IDecorator<DateTime> _)
Parameters
_
IDecorator<DateTime>The IDecorator<T> to extend.
Returns
- DateTime
A a System.DateTime initialized to midnight, January 1st, 1970 in Coordinated Universal Time (UTC).
ToDefaultKind(IDecorator<DateTime>)
Converts the enclosed System.DateTime of the decorator
to a representation that is not specified as either local time or UTC.
public static DateTime ToDefaultKind(this IDecorator<DateTime> decorator)
Parameters
decorator
IDecorator<DateTime>The IDecorator<T> to extend.
Returns
- DateTime
A new System.DateTime value initialized to System.DateTimeKind.Unspecified that has the same number of ticks as the enclosed System.DateTime of the
decorator
.
Exceptions
- System.ArgumentNullException
decorator
cannot be null.
ToLocalKind(IDecorator<DateTime>)
Converts the enclosed System.DateTime of the decorator
to a local time representation.
public static DateTime ToLocalKind(this IDecorator<DateTime> decorator)
Parameters
decorator
IDecorator<DateTime>The IDecorator<T> to extend.
Returns
- DateTime
A new System.DateTime value initialized to System.DateTimeKind.Local that has the same number of ticks as the enclosed System.DateTime of the
decorator
.
Exceptions
- System.ArgumentNullException
decorator
cannot be null.
ToUnixEpochTime(IDecorator<DateTime>)
Converts the enclosed System.DateTime of the decorator
to an equivalent UNIX Epoch time representation.
public static double ToUnixEpochTime(this IDecorator<DateTime> decorator)
Parameters
decorator
IDecorator<DateTime>The IDecorator<T> to extend.
Returns
- Double
A System.Double value that is equivalent to the enclosed System.DateTime of the
decorator
.
Remarks
This implementation converts the enclosed System.DateTime of the decorator
to an UTC representation ONLY if the System.DateTime.Kind equals System.DateTimeKind.Local.
ToUtcKind(IDecorator<DateTime>)
Converts the enclosed System.DateTime of the decorator
to a Coordinated Universal Time (UTC) representation.
public static DateTime ToUtcKind(this IDecorator<DateTime> decorator)
Parameters
decorator
IDecorator<DateTime>The IDecorator<T> to extend.
Returns
- DateTime
A new System.DateTime value initialized to System.DateTimeKind.Utc that has the same number of ticks as the object represented by the enclosed System.DateTime of the
decorator
.
Exceptions
- System.ArgumentNullException
decorator
cannot be null.