C# Class ServiceStack.Text.Common.DateTimeSerializer

显示文件 Open project: ServiceStack/ServiceStack.Text Class Usage Examples

Public Methods

Method Description
GetLocalTimeZoneInfo ( ) : TimeZoneInfo
ParseDateTime ( string dateTimeStr ) : System.DateTime
ParseDateTimeOffset ( string dateTimeOffsetStr ) : DateTimeOffset
ParseManual ( string dateTimeStr ) : DateTime?
ParseManual ( string dateTimeStr, DateTimeKind dateKind ) : DateTime?
ParseNSTimeInterval ( string doubleInSecs ) : System.TimeSpan
ParseNullableDateTimeOffset ( string dateTimeOffsetStr ) : DateTimeOffset?
ParseNullableTimeSpan ( string dateTimeStr ) : TimeSpan?
ParseRFC1123DateTime ( string dateTimeStr ) : System.DateTime
ParseShortestNullableXsdDateTime ( string dateTimeStr ) : DateTime?
ParseShortestXsdDateTime ( string dateTimeStr ) : System.DateTime
ParseTimeSpan ( string dateTimeStr ) : System.TimeSpan
ParseWcfJsonDate ( string wcfJsonDate ) : System.DateTime

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

ParseWcfJsonDateOffset ( string wcfJsonDate ) : DateTimeOffset

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

ParseXsdDateTime ( string dateTimeStr ) : System.DateTime
ParseXsdNullableTimeSpan ( string dateTimeStr ) : TimeSpan?
ParseXsdTimeSpan ( string dateTimeStr ) : System.TimeSpan
Prepare ( this dateTime, bool parsedAsUtc = false ) : System.DateTime

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

ToDateTimeString ( System.DateTime dateTime ) : string
ToLocalXsdDateTimeString ( System.DateTime dateTime ) : string
ToShortestXsdDateTimeString ( System.DateTime dateTime ) : string
ToWcfJsonDate ( System.DateTime dateTime ) : string
ToWcfJsonDateTimeOffset ( DateTimeOffset dateTimeOffset ) : string
ToXsdDateTimeString ( System.DateTime dateTime ) : string
ToXsdTimeSpanString ( System.TimeSpan timeSpan ) : string
WriteWcfJsonDate ( TextWriter writer, System.DateTime dateTime ) : void
WriteWcfJsonDateTimeOffset ( TextWriter writer, DateTimeOffset dateTimeOffset ) : void

Private Methods

Method Description
RemoveUtcOffsets ( string dateTimeStr, DateTimeKind &kind ) : string
RepairXsdTimeSeparator ( string dateTimeStr ) : string

Repairs an out-of-spec XML date/time string which incorrectly uses a space instead of a 'T' to separate the date from the time. These string are occasionally generated by SQLite and can cause errors in OrmLite when reading these columns from the DB.

Method Details

GetLocalTimeZoneInfo() public static method

public static GetLocalTimeZoneInfo ( ) : TimeZoneInfo
return System.TimeZoneInfo

ParseDateTime() public static method

public static ParseDateTime ( string dateTimeStr ) : System.DateTime
dateTimeStr string
return System.DateTime

ParseDateTimeOffset() public static method

public static ParseDateTimeOffset ( string dateTimeOffsetStr ) : DateTimeOffset
dateTimeOffsetStr string
return DateTimeOffset

ParseManual() public static method

public static ParseManual ( string dateTimeStr ) : DateTime?
dateTimeStr string
return DateTime?

ParseManual() public static method

public static ParseManual ( string dateTimeStr, DateTimeKind dateKind ) : DateTime?
dateTimeStr string
dateKind DateTimeKind
return DateTime?

ParseNSTimeInterval() public static method

public static ParseNSTimeInterval ( string doubleInSecs ) : System.TimeSpan
doubleInSecs string
return System.TimeSpan

ParseNullableDateTimeOffset() public static method

public static ParseNullableDateTimeOffset ( string dateTimeOffsetStr ) : DateTimeOffset?
dateTimeOffsetStr string
return DateTimeOffset?

ParseNullableTimeSpan() public static method

public static ParseNullableTimeSpan ( string dateTimeStr ) : TimeSpan?
dateTimeStr string
return TimeSpan?

ParseRFC1123DateTime() public static method

public static ParseRFC1123DateTime ( string dateTimeStr ) : System.DateTime
dateTimeStr string
return System.DateTime

ParseShortestNullableXsdDateTime() public static method

public static ParseShortestNullableXsdDateTime ( string dateTimeStr ) : DateTime?
dateTimeStr string
return DateTime?

ParseShortestXsdDateTime() public static method

public static ParseShortestXsdDateTime ( string dateTimeStr ) : System.DateTime
dateTimeStr string
return System.DateTime

ParseTimeSpan() public static method

public static ParseTimeSpan ( string dateTimeStr ) : System.TimeSpan
dateTimeStr string
return System.TimeSpan

ParseWcfJsonDate() public static method

WCF Json format: /Date(unixts+0000)/
public static ParseWcfJsonDate ( string wcfJsonDate ) : System.DateTime
wcfJsonDate string
return System.DateTime

ParseWcfJsonDateOffset() public static method

WCF Json format: /Date(unixts+0000)/
public static ParseWcfJsonDateOffset ( string wcfJsonDate ) : DateTimeOffset
wcfJsonDate string
return DateTimeOffset

ParseXsdDateTime() public static method

public static ParseXsdDateTime ( string dateTimeStr ) : System.DateTime
dateTimeStr string
return System.DateTime

ParseXsdNullableTimeSpan() public static method

public static ParseXsdNullableTimeSpan ( string dateTimeStr ) : TimeSpan?
dateTimeStr string
return TimeSpan?

ParseXsdTimeSpan() public static method

public static ParseXsdTimeSpan ( string dateTimeStr ) : System.TimeSpan
dateTimeStr string
return System.TimeSpan

Prepare() public static method

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
public static Prepare ( this dateTime, bool parsedAsUtc = false ) : System.DateTime
dateTime this
parsedAsUtc bool
return System.DateTime

ToDateTimeString() public static method

public static ToDateTimeString ( System.DateTime dateTime ) : string
dateTime System.DateTime
return string

ToLocalXsdDateTimeString() public static method

public static ToLocalXsdDateTimeString ( System.DateTime dateTime ) : string
dateTime System.DateTime
return string

ToShortestXsdDateTimeString() public static method

public static ToShortestXsdDateTimeString ( System.DateTime dateTime ) : string
dateTime System.DateTime
return string

ToWcfJsonDate() public static method

public static ToWcfJsonDate ( System.DateTime dateTime ) : string
dateTime System.DateTime
return string

ToWcfJsonDateTimeOffset() public static method

public static ToWcfJsonDateTimeOffset ( DateTimeOffset dateTimeOffset ) : string
dateTimeOffset DateTimeOffset
return string

ToXsdDateTimeString() public static method

public static ToXsdDateTimeString ( System.DateTime dateTime ) : string
dateTime System.DateTime
return string

ToXsdTimeSpanString() public static method

public static ToXsdTimeSpanString ( System.TimeSpan timeSpan ) : string
timeSpan System.TimeSpan
return string

WriteWcfJsonDate() public static method

public static WriteWcfJsonDate ( TextWriter writer, System.DateTime dateTime ) : void
writer TextWriter
dateTime System.DateTime
return void

WriteWcfJsonDateTimeOffset() public static method

public static WriteWcfJsonDateTimeOffset ( TextWriter writer, DateTimeOffset dateTimeOffset ) : void
writer TextWriter
dateTimeOffset DateTimeOffset
return void