Skip to main content

DateTimeExtensions

A fast, standards-based, serialization-issue free DateTime serializer.

Assembly: ServiceStack.Text.dll
View Source
Declaration
public static class DateTimeExtensions

Fields

UnixEpoch

View Source
Declaration
public const long UnixEpoch = 621355968000000000L

Methods

FromUnixTime(Int32)

View Source
Declaration
public static DateTime FromUnixTime(this int unixTime)
Returns

System.DateTime

Parameters
TypeName
System.Int32unixTime

FromUnixTime(Double)

View Source
Declaration
public static DateTime FromUnixTime(this double unixTime)
Returns

System.DateTime

Parameters
TypeName
System.DoubleunixTime

FromUnixTime(Int64)

View Source
Declaration
public static DateTime FromUnixTime(this long unixTime)
Returns

System.DateTime

Parameters
TypeName
System.Int64unixTime

ToUnixTimeMsAlt(DateTime)

View Source
Declaration
public static long ToUnixTimeMsAlt(this DateTime dateTime)
Returns

System.Int64

Parameters
TypeName
System.DateTimedateTime

ToUnixTimeMs(DateTimeOffset)

View Source
Declaration
public static long ToUnixTimeMs(this DateTimeOffset dateTimeOffset)
Returns

System.Int64

Parameters
TypeName
System.DateTimeOffsetdateTimeOffset

ToUnixTimeMs(DateTime)

View Source
Declaration
public static long ToUnixTimeMs(this DateTime dateTime)
Returns

System.Int64

Parameters
TypeName
System.DateTimedateTime

ToUnixTime(DateTime)

View Source
Declaration
public static long ToUnixTime(this DateTime dateTime)
Returns

System.Int64

Parameters
TypeName
System.DateTimedateTime

ToUnixTimeMs(Int64)

View Source
Declaration
public static long ToUnixTimeMs(this long ticks)
Returns

System.Int64

Parameters
TypeName
System.Int64ticks

FromUnixTimeMs(Double)

View Source
Declaration
public static DateTime FromUnixTimeMs(this double msSince1970)
Returns

System.DateTime

Parameters
TypeName
System.DoublemsSince1970

FromUnixTimeMs(Int64)

View Source
Declaration
public static DateTime FromUnixTimeMs(this long msSince1970)
Returns

System.DateTime

Parameters
TypeName
System.Int64msSince1970

FromUnixTimeMs(Int64, TimeSpan)

View Source
Declaration
public static DateTime FromUnixTimeMs(this long msSince1970, TimeSpan offset)
Returns

System.DateTime

Parameters
TypeName
System.Int64msSince1970
System.TimeSpanoffset

FromUnixTimeMs(Double, TimeSpan)

View Source
Declaration
public static DateTime FromUnixTimeMs(this double msSince1970, TimeSpan offset)
Returns

System.DateTime

Parameters
TypeName
System.DoublemsSince1970
System.TimeSpanoffset

FromUnixTimeMs(String)

View Source
Declaration
public static DateTime FromUnixTimeMs(string msSince1970)
Returns

System.DateTime

Parameters
TypeName
System.StringmsSince1970

FromUnixTimeMs(String, TimeSpan)

View Source
Declaration
public static DateTime FromUnixTimeMs(string msSince1970, TimeSpan offset)
Returns

System.DateTime

Parameters
TypeName
System.StringmsSince1970
System.TimeSpanoffset

RoundToMs(DateTime)

View Source
Declaration
public static DateTime RoundToMs(this DateTime dateTime)
Returns

System.DateTime

Parameters
TypeName
System.DateTimedateTime

RoundToSecond(DateTime)

View Source
Declaration
public static DateTime RoundToSecond(this DateTime dateTime)
Returns

System.DateTime

Parameters
TypeName
System.DateTimedateTime

Truncate(DateTime, TimeSpan)

View Source
Declaration
public static DateTime Truncate(this DateTime dateTime, TimeSpan timeSpan)
Returns

System.DateTime

Parameters
TypeName
System.DateTimedateTime
System.TimeSpantimeSpan

ToShortestXsdDateTimeString(DateTime)

View Source
Declaration
public static string ToShortestXsdDateTimeString(this DateTime dateTime)
Returns

System.String

Parameters
TypeName
System.DateTimedateTime

FromShortestXsdDateTimeString(String)

View Source
Declaration
public static DateTime FromShortestXsdDateTimeString(this string xsdDateTime)
Returns

System.DateTime

Parameters
TypeName
System.StringxsdDateTime

IsEqualToTheSecond(DateTime, DateTime)

View Source
Declaration
public static bool IsEqualToTheSecond(this DateTime dateTime, DateTime otherDateTime)
Returns

System.Boolean

Parameters
TypeName
System.DateTimedateTime
System.DateTimeotherDateTime

ToTimeOffsetString(TimeSpan, String)

View Source
Declaration
public static string ToTimeOffsetString(this TimeSpan offset, string seperator = "")
Returns

System.String

Parameters
TypeName
System.TimeSpanoffset
System.Stringseperator

FromTimeOffsetString(String)

View Source
Declaration
public static TimeSpan FromTimeOffsetString(this string offsetString)
Returns

System.TimeSpan

Parameters
TypeName
System.StringoffsetString

ToStableUniversalTime(DateTime)

View Source
Declaration
public static DateTime ToStableUniversalTime(this DateTime dateTime)
Returns

System.DateTime

Parameters
TypeName
System.DateTimedateTime

FmtSortableDate(DateTime)

View Source
Declaration
public static string FmtSortableDate(this DateTime from)
Returns

System.String

Parameters
TypeName
System.DateTimefrom

FmtSortableDateTime(DateTime)

View Source
Declaration
public static string FmtSortableDateTime(this DateTime from)
Returns

System.String

Parameters
TypeName
System.DateTimefrom

LastMonday(DateTime)

View Source
Declaration
public static DateTime LastMonday(this DateTime from)
Returns

System.DateTime

Parameters
TypeName
System.DateTimefrom

StartOfLastMonth(DateTime)

View Source
Declaration
public static DateTime StartOfLastMonth(this DateTime from)
Returns

System.DateTime

Parameters
TypeName
System.DateTimefrom

EndOfLastMonth(DateTime)

View Source
Declaration
public static DateTime EndOfLastMonth(this DateTime from)
Returns

System.DateTime

Parameters
TypeName
System.DateTimefrom