public void ParseSerializedCurrentDateAsISO() { var writer = new JSonWriter(); var now = DateTime.Now; // remove miliseconds: now = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, 0, now.Kind); using(writer.WriteObject()) writer.WriteMember("date", now); var reader = new JSonReader(writer.ToString()); var item = reader.ReadAsJSonObject(); var date = item["date"].DateTimeValue; Assert.AreEqual(now, date); }
public void ParseSerializedCurrentDateAsEpochSeconds() { var writer = new JSonWriter(); var now = DateTime.Now; using (writer.WriteObject()) writer.WriteMember("date", now, JSonWriterDateFormat.UnixEpochSeconds); // remove below seconds: now = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, 0, now.Kind); var reader = new JSonReader(writer.ToString()); var item = reader.ReadAsJSonObject(); var date = item["date"].ToDateTimeValue(JSonDateTimeKind.UnixEpochSeconds); Assert.AreNotEqual(0, item["date"].Int64Value); Assert.AreEqual(now, date); }