Class JsonDate
public static class JsonDate
- Inheritance
-
JsonDate
- Inherited Members
Properties
Now
public static double Now { get; }
Property Value
Methods
GetTime(DateTime)
public static double GetTime(DateTime tDate)
Parameters
tDateDateTimeEither a local time or an UTC time.
Returns
- double
Number of milliseconds since 1970-01-01 UTC. If the given date was
DateTime.MinValue, then zero will be returned.
Parse(string)
Converts a JSON string representation of a date to a DateTime value.
public static DateTime Parse(string sDate)
Parameters
sDatestringString date to convert. If this is
nullor empty, thenDateTime.MinValuewill be returned.
Returns
Remarks
Valid formats include "yyyy-MM-ddTHH:mm:ss.fffffffK" and its subsets.
Parse(string, DateTimeKind)
Converts a JSON string representation of a date to a DateTime value.
public static DateTime Parse(string sDate, DateTimeKind nDateTimeKindDefault)
Parameters
sDatestringString date to convert. If this is
nullor empty, thenDateTime.MinValuewill be returned.nDateTimeKindDefaultDateTimeKindDefault DateTimeKind which is used, if parsed DateTime.Kind equals DateTimeKind.Unspecified. A value of DateTimeKind.Unspecified is here useless.
Returns
Remarks
Valid formats include "yyyy-MM-ddTHH:mm:ss.fffffffK" and its subsets.
SetTime(double)
Converts milliseconds since 1970-01-01 UTC to a DateTime in local time.
public static DateTime SetTime(double nMilliseconds)
Parameters
nMillisecondsdoubleMilliseonds to convert. If this is zero, then
DateTime.MinValuewill be returned.
Returns
SetTimeUtc(double)
Converts milliseconds since 1970-01-01 UTC to a DateTime UTC value.
public static DateTime SetTimeUtc(double nMilliseconds)
Parameters
nMillisecondsdouble
Returns
- DateTime
A
DateTimewithDateTimeKind.Utcthat represents the JSON time given in milliseconds. If zero was given, thenDateTime.MinValuewill be returned.
ToDateString(DateTime)
Converts a DateTime value to a JSON string representation of a date.
public static string ToDateString(DateTime tDate)
Parameters
tDateDateTimeThe date value to convert.
Returns
- string
If the parameter is
DateTime.MinValue, thennullwill be returned. Otherwise a date string according to the pattern "yyyy-MM-dd" will be returned.
ToDateTimeString(DateTime)
public static string ToDateTimeString(DateTime tDate)
Parameters
tDateDateTime
Returns
ToISOString(DateTime)
Converts a DateTime value to a JSON string representation of a date.
public static string ToISOString(DateTime tDate)
Parameters
tDateDateTimeThe date value to convert.
Returns
- string
If the parameter is
DateTime.MinValue, thennullwill be returned. Otherwise the date is converted to UTC and an ISO-8601 compliant UTC date string according to the pattern "yyyy-MM-ddTHH:mm:ss.fffffffK" will be returned.