[ardoJSON] The behavior about converting JSON string including Date attribute to Record

[ardoJSON] The behavior about converting JSON string including Date attribute to Record

  
Forge Component
(21)
Published on 30 Aug by Ricardo Silva
21 votes
Published on 30 Aug by Ricardo Silva

Hi, 

I faced a problem when I tried to convert JSON string including Date attribute to Record.

The problem is following.

Assume  the time zone of server is "UTC+09:00".

In the event of UTC offset in date attribute of  JSON string is not "0" , such as "2016-10-01T00:00:00.000+08:00"(UTC+08:00), the string will be converted to "#2016-10-01 01:00:00#".

In the event of UTC offset is "0", only "Z" is attached at the end of date string as suffix , such as  "2016-10-01T00:00:00.000Z", the string of date will be converted to "#2016-10-01 00:00:00#" ( But I think it should be "#2016-10-01 09:00:00#").


It seems that above behaviors of converting date string are different, and are determined by whether "Z" suffix is attached. If "Z" suffix is attached, the date will not be calculated by time offset.

But according to rfc3339 ,

      Z           A suffix which, when applied to a time, denotes a UTC
                  offset of 00:00; often spoken "Zulu" from the ICAO
                  phonetic alphabet representation of the letter "Z".

 "Z" is meaning that UTC offset is 0 only, so I  think the behavior of conversion should be the same  no matter whether suffix "Z" is attached.

I want to know if the behavior is a bug? or is it right?


Best wishes

Hello Manshou,

I did not implement ISO 8601 conversion. I leave that to the .NET framework. Whatever behavior you're observing, is the one JSON.NET + .NET framework have for processing that kind of dates.

I will assume this behavior is correct and validated throughout all of the users of these libraries. I do not wish to make my own implementation of date/date time parsing.

The focus of ardoJSON is JSON, not the specific behaviors of date / date times. If you wish your application to have a different date/date-time semantics, you should be able to set the field as text and parse the date as you see fit.

Best regards,

Ricardo Silva