Enhanced C#
Loyc library documentation
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Public fields | Public Member Functions | List of all members
Loyc.SyncLib.Impl.SyncTimeAsString< SM > Struct Template Reference

Synchronizes DateTime, DateTimeOffset and TimeSpan values as strings. By default the formats match Newtonsoft.Json: ISO-8601 for DateTime — written in one of three forms according to its DateTimeKind (see SyncDateTimeHelper.NewtonsoftDateFormat) — and for DateTimeOffset, and constant ("c") format for TimeSpan. A different format can be chosen via the constructor. All strings are written and parsed with the invariant culture. More...


Source file:
Inheritance diagram for Loyc.SyncLib.Impl.SyncTimeAsString< SM >:
Loyc.SyncLib.ISyncField< SyncManager, T > Loyc.SyncLib.ISyncField< SyncManager, T > Loyc.SyncLib.ISyncField< SyncManager, T > Loyc.SyncLib.ISyncField< SyncManager, T > Loyc.SyncLib.ISyncField< SyncManager, T > Loyc.SyncLib.ISyncField< SyncManager, T >

Remarks

Synchronizes DateTime, DateTimeOffset and TimeSpan values as strings. By default the formats match Newtonsoft.Json: ISO-8601 for DateTime — written in one of three forms according to its DateTimeKind (see SyncDateTimeHelper.NewtonsoftDateFormat) — and for DateTimeOffset, and constant ("c") format for TimeSpan. A different format can be chosen via the constructor. All strings are written and parsed with the invariant culture.

Type Constraints
SM :ISyncManager 

Public fields

string _preferredFormat
 
DateTimeStyles _parseMode
 

Public Member Functions

 SyncTimeAsString (string?preferredFormat=null, DateTimeStyles parseMode=DateTimeStyles.AllowWhiteSpaces)
 
string ToString (DateTime value)
 
string ToString (DateTimeOffset value)
 
string ToString (TimeSpan value)
 
DateTime ToDateTime (string?str)
 
DateTimeOffset ToDateTimeOffset (string?str)
 
TimeSpan ToTimeSpan (string?str)
 
DateTime Sync (ref SM sync, FieldId name, DateTime value)
 
DateTime Sync (ref SM sync, FieldId name, DateTime?value)
 
DateTimeOffset Sync (ref SM sync, FieldId name, DateTimeOffset value)
 
DateTimeOffset Sync (ref SM sync, FieldId name, DateTimeOffset?value)
 
TimeSpan Sync (ref SM sync, FieldId name, TimeSpan value)
 
TimeSpan Sync (ref SM sync, FieldId name, TimeSpan?value)
 
- Public Member Functions inherited from Loyc.SyncLib.ISyncField< SyncManager, T >
Sync (ref SyncManager sync, FieldId name, T?value)
 

Constructor & Destructor Documentation

Loyc.SyncLib.Impl.SyncTimeAsString< SM >.SyncTimeAsString ( string?  preferredFormat = null,
DateTimeStyles  parseMode = DateTimeStyles.AllowWhiteSpaces 
)
inline
Parameters
preferredFormatThe format used for writing, which is also tried first when parsing (parsing falls back on the standard Parse method of the value's type). If this is null, DateTime and DateTimeOffset use NewtonsoftDateFormat and TimeSpan uses constant ("c") format.
parseModeStyle flags used when parsing DateTime and DateTimeOffset (e.g. DateTimeStyles.RoundtripKind preserves the DateTimeKind of a DateTime).