Class JsonDate

Namespace
Subsembly.Json
Assembly
Subsembly.Json.dll
public static class JsonDate
Inheritance
JsonDate
Inherited Members

Properties

Now

public static double Now { get; }

Property Value

double

Methods

GetTime(DateTime)

public static double GetTime(DateTime tDate)

Parameters

tDate DateTime

Either 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

sDate string

String date to convert. If this is null or empty, then DateTime.MinValue will be returned.

Returns

DateTime

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

sDate string

String date to convert. If this is null or empty, then DateTime.MinValue will be returned.

nDateTimeKindDefault DateTimeKind

Default DateTimeKind which is used, if parsed DateTime.Kind equals DateTimeKind.Unspecified. A value of DateTimeKind.Unspecified is here useless.

Returns

DateTime

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

nMilliseconds double

Milliseonds to convert. If this is zero, then DateTime.MinValue will be returned.

Returns

DateTime

SetTimeUtc(double)

Converts milliseconds since 1970-01-01 UTC to a DateTime UTC value.

public static DateTime SetTimeUtc(double nMilliseconds)

Parameters

nMilliseconds double

Returns

DateTime

A DateTime with DateTimeKind.Utc that represents the JSON time given in milliseconds. If zero was given, then DateTime.MinValue will be returned.

ToDateString(DateTime)

Converts a DateTime value to a JSON string representation of a date.

public static string ToDateString(DateTime tDate)

Parameters

tDate DateTime

The date value to convert.

Returns

string

If the parameter is DateTime.MinValue, then null will 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

tDate DateTime

Returns

string

ToISOString(DateTime)

Converts a DateTime value to a JSON string representation of a date.

public static string ToISOString(DateTime tDate)

Parameters

tDate DateTime

The date value to convert.

Returns

string

If the parameter is DateTime.MinValue, then null will 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.