forked from ln-dotnet/ln.json
25 lines
776 B
C#
25 lines
776 B
C#
// /**
|
|
// * File: JSONDateTimeConverter.cs
|
|
// * Author: haraldwolff
|
|
// *
|
|
// * This file and it's content is copyrighted by the Author and / or copyright holder.
|
|
// * Any use wihtout proper permission is illegal and may lead to legal actions.
|
|
// *
|
|
// *
|
|
// **/
|
|
using System;
|
|
|
|
namespace ln.json.mapping
|
|
{
|
|
public class JSONDateTimeOffsetMapping : JSONMapping
|
|
{
|
|
public JSONDateTimeOffsetMapping()
|
|
:base(typeof(DateTimeOffset))
|
|
{
|
|
}
|
|
|
|
public override object FromJson(JSONMapper mapper, JSONValue json) => DateTimeOffset.FromUnixTimeSeconds((long)((JSONNumber)json).Decimal);
|
|
public override JSONValue ToJson(JSONMapper mapper, object value) => new JSONNumber(((DateTimeOffset)value).ToUnixTimeSeconds());
|
|
}
|
|
}
|