Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle code editor.
Testing was doing me in. I was Serializing with: HttpResponseMessage hrm = http.PostAsJsonAsync ( sItem, tItem ).Result; And sometimes it would put fractional seconds in and sometimes not depending if fractional seconds were used or not. And this would break the above posted Deserialize's DateTimeFormat. Eventually, I just went with: using Newtonsoft.Json; which can Deserialize with: return JsonConvert.DeserializeObject( sResult ); and Serialize with: string sJ = JsonConvert.SerializeObject ( tItem ); And it works just fine without doing anything else. Michael John Episcope 7-May-13 17:18 7-May-13 17:18 Hi, From Section 3: JSON Serialization and Deserialization on DateTime, regarding the optional part like '+0500', sometimes I get a negative value for the operator like '-0500', which will not be handled by your regular expression pattern: @' /Date (( d+) + d+ ) /' I would like to confirm what that optional part is.
Is it the time zone? And when do I get a positive or a negative operator for that part? I'm always getting a positive operator on my local machine, and a sometimes a negative operator on our cloud server. That's why I guessed it is the time zone.
The optional part in the serialized value is the timezone offset from UTC. The offset represents the number of hours and minutes (+HHMM) that get added to UTC to get the representation of the local time. In my timezone, American Eastern Standard Time (EST), the offset is '-0500' during winter and '-0400' during summer because Daylight Saving Time applies. EST is 5 hours behind UTC, EDT is 4 hours behind. Put another way, if the offset is present, it indicates the value represents local time and gives you enough information to calculate it. The mandatory part is number of ticks since midnight of January 1, 1970 UTC.
Without the offset, the serialized value represents Universal aka UTC time (also called Zulu time). Just remember that Javascript always treats a date-time value as if it were in the browser's local time zone.
And you are correct, the regex pattern should be: @' /Date (( d+)-+ d+ ) /' - Ed Eaglehouse Languages broken with standards confused, No wonder I've got me the Programmer's Blues.