C# Class DateTimeEpochExtensions, extensions

Provides conversion of DateTime and DateTimeOffset into an epoch-relative number value (total seconds). See Unix Epoch in Wikipedia for more information on why this might be needed. Typical uses include using this simplified representation as an expiration time for a token, password or verification code.
Mostra file Open project: netfx/extensions

Public Methods

Method Description
ToDateTimeFromEpoch ( this secondsSince1970 ) : DateTime

Converts the given epoch time to a DateTime with DateTimeKind.Utc kind.

ToDateTimeOffsetFromEpoch ( this secondsSince1970 ) : DateTimeOffset

Converts the given epoch time to a UTC DateTimeOffset.

ToEpochTime ( this dateTime ) : long

Converts the given date value to epoch time.

Method Details

ToDateTimeFromEpoch() public static method

Converts the given epoch time to a DateTime with DateTimeKind.Utc kind.
public static ToDateTimeFromEpoch ( this secondsSince1970 ) : DateTime
secondsSince1970 this The seconds to convert
return DateTime

ToDateTimeOffsetFromEpoch() public static method

Converts the given epoch time to a UTC DateTimeOffset.
public static ToDateTimeOffsetFromEpoch ( this secondsSince1970 ) : DateTimeOffset
secondsSince1970 this The seconds to convert
return DateTimeOffset

ToEpochTime() public static method

Converts the given date value to epoch time.
public static ToEpochTime ( this dateTime ) : long
dateTime this The data to convert
return long