mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 05:05:05 +00:00
feat: Adding JsonReader extension to read current value as DateTime
This commit is contained in:
@@ -22,6 +22,16 @@ namespace ICD.Common.Utils.Json
|
||||
private const string MESSAGE_NAME_PROPERTY = "m";
|
||||
private const string MESSAGE_DATA_PROPERTY = "d";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the data as a DateTime value.
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public static DateTime ParseDateTime(string data)
|
||||
{
|
||||
return DateTime.ParseExact(data, DATE_FORMAT, CultureInfo.CurrentCulture);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the token as a DateTime value.
|
||||
/// </summary>
|
||||
@@ -34,7 +44,7 @@ namespace ICD.Common.Utils.Json
|
||||
throw new ArgumentNullException("token");
|
||||
|
||||
#if SIMPLSHARP
|
||||
return DateTime.ParseExact((string)token, DATE_FORMAT, CultureInfo.CurrentCulture);
|
||||
return ParseDateTime((string)token);
|
||||
#else
|
||||
return (DateTime)token;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user