ssmoon / Jil

Fork from https://github.com/kevin-montrose/Jil, add some code to ensure the DateTime property is deserialized to LocalTime, not the UTC time.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Jil

A fast JSON (de)serializer, built on Sigil with a number of somewhat crazy optimization tricks.

Forked from https://github.com/kevin-montrose/Jil, to ensure the DateTime property is deserialized to LocalTime, not the UTC time.

Just add some code in InlineDeserializer.cs ==> ReadNewtosoftDateTime(), before last "ExpectQuote",add:

var toLocalTime = typeof(DateTime).GetMethod("ToLocalTime");
    using (var loc = Emit.DeclareLocal<DateTime>())
    {
        Emit.StoreLocal(loc); // TextWriter
        Emit.LoadLocalAddress(loc); // TextWriter DateTime*
        Emit.Call(toLocalTime); // TextWriter DateTime
        Emit.StoreLocal(loc); // TextWriter
        Emit.LoadLocalAddress(loc); // TextWriter DateTime*
    }

then the output datetime will be local datetime, not the UTC's.

About

Fork from https://github.com/kevin-montrose/Jil, add some code to ensure the DateTime property is deserialized to LocalTime, not the UTC time.

License:MIT License


Languages

Language:C# 97.8%Language:Smalltalk 2.2%