Class DateUtils
Provides core date/time-related utility functions used by the majority of projects
Inheritance
System.Object
DateUtils
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Azos
Assembly: Azos.dll
Syntax
public static class DateUtils
Fields
UNIX_EPOCH_START_DATE
Declaration
public static readonly DateTime UNIX_EPOCH_START_DATE
Field Value
Type |
Description |
System.DateTime |
|
Methods
ApproximateTimeDistance(DateTime, DateTime)
Returns an approximate string represention of the point in time relative to this one,
in the most suitable scale, that is: "1 year ago" or "in 1 year"; "45 minutes ago" or "in 45 minutes". Supports ISO_LANG=eng only
Declaration
public static string ApproximateTimeDistance(this DateTime fromDate, DateTime toDate)
Parameters
Type |
Name |
Description |
System.DateTime |
fromDate |
|
System.DateTime |
toDate |
|
Returns
Type |
Description |
System.String |
|
FromMicrosecondsSinceUnixEpochStart(Int64)
Gets UTC DateTime from number of microseconds since Unix epoch start (1970/1/1 0:0:0)
Declaration
public static DateTime FromMicrosecondsSinceUnixEpochStart(this long when)
Parameters
Type |
Name |
Description |
System.Int64 |
when |
|
Returns
Type |
Description |
System.DateTime |
|
FromMicrosecondsSinceUnixEpochStart(UInt64)
Gets UTC DateTime from number of microseconds since Unix epoch start (1970/1/1 0:0:0)
Declaration
public static DateTime FromMicrosecondsSinceUnixEpochStart(this ulong when)
Parameters
Type |
Name |
Description |
System.UInt64 |
when |
|
Returns
Type |
Description |
System.DateTime |
|
FromMillisecondsSinceUnixEpochStart(Int64)
Gets UTC DateTime from number of milliseconds since Unix epoch start (1970/1/1 0:0:0)
Declaration
public static DateTime FromMillisecondsSinceUnixEpochStart(this long when)
Parameters
Type |
Name |
Description |
System.Int64 |
when |
|
Returns
Type |
Description |
System.DateTime |
|
FromMillisecondsSinceUnixEpochStart(UInt64)
Gets UTC DateTime from number of milliseconds since Unix epoch start (1970/1/1 0:0:0)
Declaration
public static DateTime FromMillisecondsSinceUnixEpochStart(this ulong when)
Parameters
Type |
Name |
Description |
System.UInt64 |
when |
|
Returns
Type |
Description |
System.DateTime |
|
FromSecondsSinceUnixEpochStart(Int64)
Gets UTC DateTime from number of seconds since Unix epoch start (1970/1/1 0:0:0)
Declaration
public static DateTime FromSecondsSinceUnixEpochStart(this long when)
Parameters
Type |
Name |
Description |
System.Int64 |
when |
|
Returns
Type |
Description |
System.DateTime |
|
FromSecondsSinceUnixEpochStart(UInt64)
Gets UTC DateTime from number of seconds since Unix epoch start (1970/1/1 0:0:0)
Declaration
public static DateTime FromSecondsSinceUnixEpochStart(this ulong when)
Parameters
Type |
Name |
Description |
System.UInt64 |
when |
|
Returns
Type |
Description |
System.DateTime |
|
RoundToNextWeekDay(DateTime, DayOfWeek, Boolean)
Round date to next specific week day
Declaration
public static DateTime RoundToNextWeekDay(this DateTime now, DayOfWeek dayOfWeek, bool keepTime = false)
Parameters
Type |
Name |
Description |
System.DateTime |
now |
|
System.DayOfWeek |
dayOfWeek |
|
System.Boolean |
keepTime |
|
Returns
Type |
Description |
System.DateTime |
|
RoundToWeekDay(DateTime, DayOfWeek, Boolean)
Round date to specific week day
Declaration
public static DateTime RoundToWeekDay(this DateTime now, DayOfWeek dayOfWeek, bool keepTime = false)
Parameters
Type |
Name |
Description |
System.DateTime |
now |
|
System.DayOfWeek |
dayOfWeek |
|
System.Boolean |
keepTime |
|
Returns
Type |
Description |
System.DateTime |
|
ToMicrosecondsSinceUnixEpochStart(DateTime)
Gets number of microseconds since Unix epoch start (1970/1/1 0:0:0)
Declaration
public static long ToMicrosecondsSinceUnixEpochStart(this DateTime when)
Parameters
Type |
Name |
Description |
System.DateTime |
when |
|
Returns
Type |
Description |
System.Int64 |
|
ToMillisecondsSinceUnixEpochStart(DateTime)
Gets number of milliseconds since Unix epoch start (1970/1/1 0:0:0)
Declaration
public static long ToMillisecondsSinceUnixEpochStart(this DateTime when)
Parameters
Type |
Name |
Description |
System.DateTime |
when |
|
Returns
Type |
Description |
System.Int64 |
|
ToSecondsSinceUnixEpochStart(DateTime)
Gets number of seconds since Unix epoch start (1970/1/1 0:0:0)
Declaration
public static long ToSecondsSinceUnixEpochStart(this DateTime when)
Parameters
Type |
Name |
Description |
System.DateTime |
when |
|
Returns
Type |
Description |
System.Int64 |
|
Truncate(DateTime, Int64)
Tuncate date to specific resolution
Declaration
public static DateTime Truncate(this DateTime now, long tickResolution)
Parameters
Type |
Name |
Description |
System.DateTime |
now |
|
System.Int64 |
tickResolution |
|
Returns
Type |
Description |
System.DateTime |
|