-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from bb-io/develop
Develop
- Loading branch information
Showing
5 changed files
with
72 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Apps.BWX.Converters | ||
{ | ||
public class DateTimeConverter : JsonConverter<DateTime> | ||
{ | ||
public override DateTime ReadJson(JsonReader reader, Type objectType, DateTime existingValue, bool hasExistingValue, JsonSerializer serializer) | ||
{ | ||
if (reader.TokenType == JsonToken.Integer) | ||
{ | ||
DateTime start = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); | ||
return start.AddMilliseconds(long.Parse(reader.Value.ToString())).ToLocalTime(); | ||
} | ||
|
||
throw new JsonException("The JSON value could not be converted to DateTime."); | ||
} | ||
|
||
public override void WriteJson(JsonWriter writer, DateTime value, JsonSerializer serializer) | ||
{ | ||
writer.WriteValue(value.ToString()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters