Class JsonDate
Inheritance
System.Object
JsonDate
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Assembly: Subsembly.Json.dll
Syntax
public static class JsonDate
Properties
Now
Declaration
public static double Now { get; }
Property Value
Type |
Description |
System.Double |
|
Methods
GetTime(DateTime)
Declaration
public static double GetTime(DateTime tDate)
Parameters
Type |
Name |
Description |
System.DateTime |
tDate |
Either a local time or an UTC time.
|
Returns
Type |
Description |
System.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.
Declaration
public static DateTime Parse(string sDate)
Parameters
Type |
Name |
Description |
System.String |
sDate |
String date to convert. If this is null or empty, then
DateTime.MinValue will be returned.
|
Returns
Type |
Description |
System.DateTime |
|
SetTime(Double)
Converts milliseconds since 1970-01-01 UTC to a DateTime
in local time.
Declaration
public static DateTime SetTime(double nMilliseconds)
Parameters
Type |
Name |
Description |
System.Double |
nMilliseconds |
Milliseonds to convert. If this is zero, then DateTime.MinValue will be
returned.
|
Returns
Type |
Description |
System.DateTime |
|
SetTimeUtc(Double)
Converts milliseconds since 1970-01-01 UTC to a DateTime
UTC value.
Declaration
public static DateTime SetTimeUtc(double nMilliseconds)
Parameters
Type |
Name |
Description |
System.Double |
nMilliseconds |
|
Returns
Type |
Description |
System.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.
Declaration
public static string ToDateString(DateTime tDate)
Parameters
Type |
Name |
Description |
System.DateTime |
tDate |
The date value to convert.
|
Returns
Type |
Description |
System.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)
Declaration
public static string ToDateTimeString(DateTime tDate)
Parameters
Type |
Name |
Description |
System.DateTime |
tDate |
|
Returns
Type |
Description |
System.String |
|
ToISOString(DateTime)
Converts a DateTime
value to a JSON string representation of a date.
Declaration
public static string ToISOString(DateTime tDate)
Parameters
Type |
Name |
Description |
System.DateTime |
tDate |
The date value to convert.
|
Returns
Type |
Description |
System.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.fffffffZ" will be returned.
|