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.
Afficher le fichier Open project: netfx/extensions

Méthodes publiques

Méthode 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 méthode

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

ToDateTimeOffsetFromEpoch() public static méthode

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

ToEpochTime() public static méthode

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