feat: Adding JsonReader extension to read current value as DateTime

This commit is contained in:
Chris Cameron
2019-03-31 20:38:22 -04:00
parent 24601b0ef2
commit 134ee85067
2 changed files with 26 additions and 1 deletions

View File

@@ -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