Fable/NewtonSoft : JsonConvert problem with DateTime

Created on 14 Dec 2016  ·  3Comments  ·  Source: fable-compiler/Fable

Hello, I am having with DateTime type over json.

type Record =
  { Id: int
    Name: string
    Time: int16
    Start: DateTime
    StartDisplay: string
    Note: string
  }

let data1 =
  { Id = x.Id
    Name = x.Name
    Time = x.Time
    Start = DateTime(2016, 12, 13, 8, 00, 0)
    StartDisplay = x.Start.ToString("hh:mm")
    Note = x.Note
  }

let JSON data =
    JsonConvert.SerializeObject(data, Fable.JsonConverter())

When serializing data1 on the browser, Start is equal to 2016-12-13T08:00:00 (value printed in the console) so it's not a DateTime and just a string.

A DateTime is printed like this in the console:
[date] Wed Dec 14 2016 15:13:40 GMT+0100 (Paris, Madrid)[date] Wed Dec 14 2016 15:13:40 GMT+0100 (Paris, Madrid)

bug

All 3 comments

Can you please try with Fable.JsonConverter 0.1.0?

Yes, will test it tomorrow :)

I stumbled upon some edge cases with non-default culture environments and with DateTime.Kind = Unspecified roundtripping. More info here https://github.com/fable-compiler/Fable/pull/613.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MangelMaxime picture MangelMaxime  ·  3Comments

tomcl picture tomcl  ·  4Comments

AngelMunoz picture AngelMunoz  ·  4Comments

SirUppyPancakes picture SirUppyPancakes  ·  3Comments

alfonsogarciacaro picture alfonsogarciacaro  ·  3Comments