Show / Hide Table of Contents

Class DateTimeExtensions

Contains useful extensions of the DateTime structure.

Inheritance
object
DateTimeExtensions
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: TheXDS.MCART.Types.Extensions
Assembly: MCART.dll
Syntax
public static class DateTimeExtensions

Fields

| Edit this page View Source

CenturyEpoch

Gets a DateTime that represents the beginning of the 20th century time.

Declaration
public static readonly DateTime CenturyEpoch
Field Value
Type Description
DateTime
Remarks

The Century Epoch is defined as the starting point of time for many 32-bit devices that do not follow the Unix standard, and is set as the first of January of the year 1900. The standard was defined by means of GMT time, in its absence UTC is used as a sufficiently close substitute.

| Edit this page View Source

UnixEpoch

Gets a DateTime that represents the beginning of the Unix time.

Declaration
public static readonly DateTime UnixEpoch
Field Value
Type Description
DateTime
| Edit this page View Source

Y2KEpoch

Gets a DateTime that represents the beginning of the 21st century time.

Declaration
public static readonly DateTime Y2KEpoch
Field Value
Type Description
DateTime
Remarks

The Y2K Epoch is defined as the starting point of time for 32-bit devices that do not follow the Unix standard, and is set as the first of January of the year 2000.

Methods

| Edit this page View Source

Epoch(in int)

Creates a DateTime that represents the beginning of time for a specific year.

Declaration
public static DateTime Epoch(in int year)
Parameters
Type Name Description
int year
Returns
Type Description
DateTime
| Edit this page View Source

FromTimestamp(in long, in DateTime)

Gets a DateTime from a Timestamp.

Declaration
public static DateTime FromTimestamp(in long seconds, in DateTime epoch)
Parameters
Type Name Description
long seconds

Number of seconds since the specified Epoch.

DateTime epoch

Initial epoch to use.

Returns
Type Description
DateTime

A DateTime constructed from the Timestamp.

| Edit this page View Source

FromTimestampMs(in long, in DateTime)

Gets a DateTime from a Timestamp in milliseconds.

Declaration
public static DateTime FromTimestampMs(in long milliseconds, in DateTime epoch)
Parameters
Type Name Description
long milliseconds

Number of seconds since the specified Epoch.

DateTime epoch

Initial epoch to use.

Returns
Type Description
DateTime

A DateTime constructed from the Timestamp.

| Edit this page View Source

FromUnixTimestamp(in long)

Gets a DateTime from a Unix Timestamp.

Declaration
public static DateTime FromUnixTimestamp(this in long seconds)
Parameters
Type Name Description
long seconds

Number of seconds since the Unix Epoch.

Returns
Type Description
DateTime

A DateTime constructed from the Unix Timestamp.

| Edit this page View Source

FromUnixTimestampMs(in long)

Gets a DateTime from a Unix Timestamp.

Declaration
public static DateTime FromUnixTimestampMs(this in long milliseconds)
Parameters
Type Name Description
long milliseconds

Number of milliseconds since the Unix Epoch.

Returns
Type Description
DateTime

A DateTime constructed from the Unix Timestamp.

| Edit this page View Source

MonthName(in int)

Gets the name of the specified month.

Declaration
public static string MonthName(in int month)
Parameters
Type Name Description
int month

Month number from which to get the name.

Returns
Type Description
string

The name of the month specified.

Exceptions
Type Condition
ArgumentOutOfRangeException

This is thrown if month does not represent a valid month number.

| Edit this page View Source

MonthName(in int, in CultureInfo)

Gets the name of the specified month.

Declaration
public static string MonthName(in int month, in CultureInfo culture)
Parameters
Type Name Description
int month

Month number from which to get the name.

CultureInfo culture

Culture to use to get the name.

Returns
Type Description
string

The name of the month specified.

Exceptions
Type Condition
ArgumentOutOfRangeException

This is thrown if month does not represent a valid month number.

| Edit this page View Source

ToTimestamp(in DateTime, in DateTime)

Converts a DateTime to a 64-bit Timestamp.

Declaration
public static long ToTimestamp(this in DateTime dateTime, in DateTime epoch)
Parameters
Type Name Description
DateTime dateTime

Time value to convert.

DateTime epoch

Initial epoch to use.

Returns
Type Description
long

A long that represents the value of the Timestamp of the specified DateTime.

| Edit this page View Source

ToTimestampMs(in DateTime, in DateTime)

Converts a DateTime to a 64-bit Timestamp.

Declaration
public static long ToTimestampMs(this in DateTime dateTime, in DateTime epoch)
Parameters
Type Name Description
DateTime dateTime

Time value to convert.

DateTime epoch

Initial epoch to use.

Returns
Type Description
long

A long that represents the value of the Timestamp of the specified DateTime.

| Edit this page View Source

ToUnixTimestamp(in DateTime)

Converts a DateTime to a 64-bit Unix Timestamp.

Declaration
public static long ToUnixTimestamp(this in DateTime dateTime)
Parameters
Type Name Description
DateTime dateTime

Time value to convert.

Returns
Type Description
long

A long that represents the value of the Unix Timestamp of the specified DateTime.

| Edit this page View Source

ToUnixTimestampMs(in DateTime)

Converts a DateTime to a 64-bit Unix Timestamp in milliseconds.

Declaration
public static long ToUnixTimestampMs(this in DateTime dateTime)
Parameters
Type Name Description
DateTime dateTime

Time value to convert.

Returns
Type Description
long

A long that represents the value of the Unix Timestamp in milliseconds of the specified DateTime.

  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX