Skip to main content

DateTimeSerializer

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

Properties

OnParseErrorFn

View Source
Declaration
public static Func<string, Exception, DateTime> OnParseErrorFn { get; set; }

Fields

CondensedDateTimeFormat

View Source
Declaration
public const string CondensedDateTimeFormat = "yyyyMMdd"

ShortDateTimeFormat

View Source
Declaration
public const string ShortDateTimeFormat = "yyyy-MM-dd"

DefaultDateTimeFormat

View Source
Declaration
public const string DefaultDateTimeFormat = "dd/MM/yyyy HH:mm:ss"

DefaultDateTimeFormatWithFraction

View Source
Declaration
public const string DefaultDateTimeFormatWithFraction = "dd/MM/yyyy HH:mm:ss.fff"

XsdDateTimeFormat

View Source
Declaration
public const string XsdDateTimeFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"

XsdDateTimeFormat3F

View Source
Declaration
public const string XsdDateTimeFormat3F = "yyyy-MM-ddTHH:mm:ss.fffZ"

XsdDateTimeFormatSeconds

View Source
Declaration
public const string XsdDateTimeFormatSeconds = "yyyy-MM-ddTHH:mm:ssZ"

DateTimeFormatSecondsUtcOffset

View Source
Declaration
public const string DateTimeFormatSecondsUtcOffset = "yyyy-MM-ddTHH:mm:sszzz"

DateTimeFormatSecondsNoOffset

View Source
Declaration
public const string DateTimeFormatSecondsNoOffset = "yyyy-MM-ddTHH:mm:ss"

DateTimeFormatTicksUtcOffset

View Source
Declaration
public const string DateTimeFormatTicksUtcOffset = "yyyy-MM-ddTHH:mm:ss.fffffffzzz"

DateTimeFormatTicksNoUtcOffset

View Source
Declaration
public const string DateTimeFormatTicksNoUtcOffset = "yyyy-MM-ddTHH:mm:ss.fffffff"

EscapedWcfJsonPrefix

View Source
Declaration
public const string EscapedWcfJsonPrefix = "\\/Date("

EscapedWcfJsonSuffix

View Source
Declaration
public const string EscapedWcfJsonSuffix = ")\\/"

WcfJsonPrefix

View Source
Declaration
public const string WcfJsonPrefix = "/Date("

WcfJsonSuffix

View Source
Declaration
public const char WcfJsonSuffix = ')'

UnspecifiedOffset

View Source
Declaration
public const string UnspecifiedOffset = "-0000"

UtcOffset

View Source
Declaration
public const string UtcOffset = "+0000"

Methods

Prepare(DateTime, Boolean)

If AlwaysUseUtc is set to true then convert all DateTime to UTC. If PreserveUtc is set to true then UTC dates will not convert to local

View Source
Declaration
public static DateTime Prepare(this DateTime dateTime, bool parsedAsUtc = false)
Returns

System.DateTime

Parameters
TypeName
System.DateTimedateTime
System.BooleanparsedAsUtc

ParseShortestNullableXsdDateTime(String)

View Source
Declaration
public static DateTime? ParseShortestNullableXsdDateTime(string dateTimeStr)
Returns

System.Nullable<System.DateTime>

Parameters
TypeName
System.StringdateTimeStr

ParseRFC1123DateTime(String)

View Source
Declaration
public static DateTime ParseRFC1123DateTime(string dateTimeStr)
Returns

System.DateTime

Parameters
TypeName
System.StringdateTimeStr

ParseShortestXsdDateTime(String)

View Source
Declaration
public static DateTime ParseShortestXsdDateTime(string dateTimeStr)
Returns

System.DateTime

Parameters
TypeName
System.StringdateTimeStr

ParseManual(String)

View Source
Declaration
public static DateTime? ParseManual(string dateTimeStr)
Returns

System.Nullable<System.DateTime>

Parameters
TypeName
System.StringdateTimeStr

ParseManual(String, DateTimeKind)

View Source
Declaration
public static DateTime? ParseManual(string dateTimeStr, DateTimeKind dateKind)
Returns

System.Nullable<System.DateTime>

Parameters
TypeName
System.StringdateTimeStr
System.DateTimeKinddateKind

ToDateTimeString(DateTime)

View Source
Declaration
public static string ToDateTimeString(DateTime dateTime)
Returns

System.String

Parameters
TypeName
System.DateTimedateTime

ParseDateTime(String)

View Source
Declaration
public static DateTime ParseDateTime(string dateTimeStr)
Returns

System.DateTime

Parameters
TypeName
System.StringdateTimeStr

ParseDateTimeOffset(String)

View Source
Declaration
public static DateTimeOffset ParseDateTimeOffset(string dateTimeOffsetStr)
Returns

System.DateTimeOffset

Parameters
TypeName
System.StringdateTimeOffsetStr

ParseNullableDateTimeOffset(String)

View Source
Declaration
public static DateTimeOffset? ParseNullableDateTimeOffset(string dateTimeOffsetStr)
Returns

System.Nullable<System.DateTimeOffset>

Parameters
TypeName
System.StringdateTimeOffsetStr

ToXsdDateTimeString(DateTime)

View Source
Declaration
public static string ToXsdDateTimeString(DateTime dateTime)
Returns

System.String

Parameters
TypeName
System.DateTimedateTime

ToLocalXsdDateTimeString(DateTime)

View Source
Declaration
public static string ToLocalXsdDateTimeString(DateTime dateTime)
Returns

System.String

Parameters
TypeName
System.DateTimedateTime

ToXsdTimeSpanString(TimeSpan)

View Source
Declaration
public static string ToXsdTimeSpanString(TimeSpan timeSpan)
Returns

System.String

Parameters
TypeName
System.TimeSpantimeSpan

ToXsdTimeSpanString(Nullable<TimeSpan>)

View Source
Declaration
public static string ToXsdTimeSpanString(TimeSpan? timeSpan)
Returns

System.String

Parameters
TypeName
System.Nullable<System.TimeSpan>timeSpan

ParseXsdDateTime(String)

View Source
Declaration
public static DateTime ParseXsdDateTime(string dateTimeStr)
Returns

System.DateTime

Parameters
TypeName
System.StringdateTimeStr

ParseTimeSpan(String)

View Source
Declaration
public static TimeSpan ParseTimeSpan(string dateTimeStr)
Returns

System.TimeSpan

Parameters
TypeName
System.StringdateTimeStr

ParseNSTimeInterval(String)

View Source
Declaration
public static TimeSpan ParseNSTimeInterval(string doubleInSecs)
Returns

System.TimeSpan

Parameters
TypeName
System.StringdoubleInSecs

ParseNullableTimeSpan(String)

View Source
Declaration
public static TimeSpan? ParseNullableTimeSpan(string dateTimeStr)
Returns

System.Nullable<System.TimeSpan>

Parameters
TypeName
System.StringdateTimeStr

ParseXsdTimeSpan(String)

View Source
Declaration
public static TimeSpan ParseXsdTimeSpan(string dateTimeStr)
Returns

System.TimeSpan

Parameters
TypeName
System.StringdateTimeStr

ParseXsdNullableTimeSpan(String)

View Source
Declaration
public static TimeSpan? ParseXsdNullableTimeSpan(string dateTimeStr)
Returns

System.Nullable<System.TimeSpan>

Parameters
TypeName
System.StringdateTimeStr

ToShortestXsdDateTimeString(DateTime)

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

System.String

Parameters
TypeName
System.DateTimedateTime

ParseWcfJsonDateOffset(String)

WCF Json format: /Date(unixts+0000)/

View Source
Declaration
public static DateTimeOffset ParseWcfJsonDateOffset(string wcfJsonDate)
Returns

System.DateTimeOffset

Parameters
TypeName
System.StringwcfJsonDate

ParseWcfJsonDate(String)

WCF Json format: /Date(unixts+0000)/

View Source
Declaration
public static DateTime ParseWcfJsonDate(string wcfJsonDate)
Returns

System.DateTime

Parameters
TypeName
System.StringwcfJsonDate

GetLocalTimeZoneInfo()

View Source
Declaration
public static TimeZoneInfo GetLocalTimeZoneInfo()
Returns

System.TimeZoneInfo

WriteWcfJsonDate(TextWriter, DateTime)

View Source
Declaration
public static void WriteWcfJsonDate(TextWriter writer, DateTime dateTime)
Parameters
TypeName
System.IO.TextWriterwriter
System.DateTimedateTime

ToWcfJsonDate(DateTime)

View Source
Declaration
public static string ToWcfJsonDate(DateTime dateTime)
Returns

System.String

Parameters
TypeName
System.DateTimedateTime

WriteWcfJsonDateTimeOffset(TextWriter, DateTimeOffset)

View Source
Declaration
public static void WriteWcfJsonDateTimeOffset(TextWriter writer, DateTimeOffset dateTimeOffset)
Parameters
TypeName
System.IO.TextWriterwriter
System.DateTimeOffsetdateTimeOffset

ToWcfJsonDateTimeOffset(DateTimeOffset)

View Source
Declaration
public static string ToWcfJsonDateTimeOffset(DateTimeOffset dateTimeOffset)
Returns

System.String

Parameters
TypeName
System.DateTimeOffsetdateTimeOffset