Table of Contents

Class DateTimeExtensions

Namespace
BSGameLib.Core
Assembly
BSGameLib.Core.dll

Converts between DateTime and Unix time.

public static class DateTimeExtensions
Inheritance
DateTimeExtensions
Inherited Members

Methods

FromUnixTimestamp(long)

Returns the time of a Unix timestamp in seconds, as a UTC DateTime (Kind Utc).

public static DateTime FromUnixTimestamp(this long timestamp)

Parameters

timestamp long

Returns

DateTime

ToUnixTimestamp(DateTime)

Returns the whole seconds from 1970-01-01 UTC to dateTime. A fraction of a second is dropped.

public static long ToUnixTimestamp(this DateTime dateTime)

Parameters

dateTime DateTime

Returns

long

Remarks

An Unspecified DateTime is taken as local time, as DateTimeOffset does. What FromUnixTimestamp(long) returns is UTC, so it converts back to the same timestamp.