27 lines
781 B
C#
27 lines
781 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;
|
|
using ln.json;
|
|
using ln.type;
|
|
|
|
namespace ln.json.mapping
|
|
{
|
|
public class JSONDateTimeMapping : JSONMapping
|
|
{
|
|
public JSONDateTimeMapping()
|
|
:base(typeof(DateTime))
|
|
{
|
|
}
|
|
|
|
public override object FromJson(JSONMapper mapper, JSONValue json) => DateTimeExtensions.FromUnixTimeSeconds(((JSONNumber)json).AsDouble);
|
|
public override JSONValue ToJson(JSONMapper mapper, object value) => new JSONNumber(((DateTime)value).ToUnixTimeSeconds());
|
|
}
|
|
}
|