Class DateTimeExtensions
This is an extensions implementation of the System.DateTime structure using methods already found in the Microsoft .NET Framework.
Inheritance
Namespace: Cuemon
Assembly: Cuemon.Core.dll
Syntax
public static class DateTimeExtensions
Methods
| Improve this DocCeiling(DateTime, Double, TimeUnit)
Returns a System.DateTime value that is rounded towards positive infinity.
Declaration
public static DateTime Ceiling(this DateTime value, double interval, TimeUnit timeUnit)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | value | A System.DateTime value to be rounded. |
System.Double | interval | The System.Double value that in combination with |
TimeUnit | timeUnit | One of the enumeration values that specifies the time unit of |
Returns
Type | Description |
---|---|
System.DateTime | A System.DateTime value that is rounded towards positive infinity. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException |
|
Ceiling(DateTime, TimeSpan)
Returns a System.DateTime value that is rounded towards positive infinity.
Declaration
public static DateTime Ceiling(this DateTime value, TimeSpan interval)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | value | A System.DateTime value to be rounded. |
System.TimeSpan | interval | The System.TimeSpan value that specifies the rounding of |
Returns
Type | Description |
---|---|
System.DateTime | A System.DateTime value that is rounded towards positive infinity. |
Floor(DateTime, Double, TimeUnit)
Returns a System.DateTime value that is rounded towards negative infinity.
Declaration
public static DateTime Floor(this DateTime value, double interval, TimeUnit timeUnit)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | value | A System.DateTime value to be rounded. |
System.Double | interval | The System.Double value that in combination with |
TimeUnit | timeUnit | One of the enumeration values that specifies the time unit of |
Returns
Type | Description |
---|---|
System.DateTime | A System.DateTime value that is rounded towards negative infinity. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException |
|
Floor(DateTime, TimeSpan)
Returns a System.DateTime value that is rounded towards negative infinity.
Declaration
public static DateTime Floor(this DateTime value, TimeSpan interval)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | value | A System.DateTime value to be rounded. |
System.TimeSpan | interval | The System.TimeSpan value that specifies the rounding of |
Returns
Type | Description |
---|---|
System.DateTime | A System.DateTime value that is rounded towards negative infinity. |
IsTimeOfDayAfternoon(DateTime)
Determines whether the specified dt
is within Afternoon.
Declaration
public static bool IsTimeOfDayAfternoon(this DateTime dt)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dt | The System.DateTime to compare. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsTimeOfDayEvening(DateTime)
Determines whether the specified dt
is within Evening.
Declaration
public static bool IsTimeOfDayEvening(this DateTime dt)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dt | The System.DateTime to compare. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsTimeOfDayForenoon(DateTime)
Determines whether the specified dt
is within Forenoon.
Declaration
public static bool IsTimeOfDayForenoon(this DateTime dt)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dt | The System.DateTime to compare. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsTimeOfDayMorning(DateTime)
Determines whether the specified dt
is within Morning.
Declaration
public static bool IsTimeOfDayMorning(this DateTime dt)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dt | The System.DateTime to compare. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsTimeOfDayNight(DateTime)
Determines whether the specified dt
is within Night.
Declaration
public static bool IsTimeOfDayNight(this DateTime dt)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dt | The System.DateTime to compare. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsWithinRange(DateTime, TimeRange)
Determines whether the specified dt
is within range
.
Declaration
public static bool IsWithinRange(this DateTime dt, TimeRange range)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dt | The System.DateTime to compare. |
TimeRange | range | The TimeRange of |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsWithinRange(DateTime, DateTime, DateTime)
Determines whether the specified dt
is within range of min
and max
.
Declaration
public static bool IsWithinRange(this DateTime dt, DateTime min, DateTime max)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dt | The System.DateTime to compare. |
System.DateTime | min | The minimum value of |
System.DateTime | max | The maximum value of |
Returns
Type | Description |
---|---|
System.Boolean |
|
Round(DateTime, Double, TimeUnit, VerticalDirection)
Returns a System.DateTime value that is rounded either towards negative infinity or positive infinity.
Declaration
public static DateTime Round(this DateTime value, double interval, TimeUnit timeUnit, VerticalDirection direction)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | value | A System.DateTime value to be rounded. |
System.Double | interval | The System.Double value that in combination with |
TimeUnit | timeUnit | One of the enumeration values that specifies the time unit of |
VerticalDirection | direction | One of the enumeration values that specifies the direction of the rounding. |
Returns
Type | Description |
---|---|
System.DateTime | A System.DateTime value that is rounded either towards negative infinity or positive infinity. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException |
|
System.ArgumentOutOfRangeException |
|
Round(DateTime, TimeSpan, VerticalDirection)
Returns a System.DateTime value that is rounded either towards negative infinity or positive infinity.
Declaration
public static DateTime Round(this DateTime value, TimeSpan interval, VerticalDirection direction)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | value | A System.DateTime value to be rounded. |
System.TimeSpan | interval | The System.TimeSpan value that specifies the rounding of |
VerticalDirection | direction | One of the enumeration values that specifies the direction of the rounding. |
Returns
Type | Description |
---|---|
System.DateTime | A System.DateTime value that is rounded either towards negative infinity or positive infinity. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException |
|
System.ArgumentOutOfRangeException |
|
ToDefaultKind(DateTime)
Converts the specified value
to a representation that is not specified as either local time or UTC.
Declaration
public static DateTime ToDefaultKind(this DateTime value)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | value | The value to convert. |
Returns
Type | Description |
---|---|
System.DateTime | A new System.DateTime value initialized to System.DateTimeKind.Unspecified that has the same number of ticks as the object represented by the |
ToLocalKind(DateTime)
Converts the specified value
to a local time representation.
Declaration
public static DateTime ToLocalKind(this DateTime value)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | value | The value to convert. |
Returns
Type | Description |
---|---|
System.DateTime | A new System.DateTime value initialized to System.DateTimeKind.Local that has the same number of ticks as the object represented by the |
ToUtcKind(DateTime)
Converts the specified value
to a Coordinated Universal Time (UTC) representation.
Declaration
public static DateTime ToUtcKind(this DateTime value)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | value | The value to convert. |
Returns
Type | Description |
---|---|
System.DateTime | A new System.DateTime value initialized to System.DateTimeKind.Utc that has the same number of ticks as the object represented by the |