C# Class HermaFx.DateTimeEpochExtensions

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.
显示文件 Open project: evicertia/HermaFx

Public Methods

Method Description
ToDateTime ( this secondsSince1970 ) : System.DateTime

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

ToDateTimeOffset ( this secondsSince1970 ) : DateTimeOffset

Converts the given epoch time to a UTC DateTimeOffset.

ToUnixTime ( this dateTime ) : long

Converts the given date value to epoch/unix time.

Method Details

ToDateTime() public static method

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

ToDateTimeOffset() public static method

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

ToUnixTime() public static method

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