///<summary> ///</summary> ///<param name="writer"></param> ///<param name="value"></param> public override void WriteJson(JsonWriter writer, object value) { System.DateTime dateTime = (System.DateTime)value; long javaScriptTicks = JavaScriptConvert.ConvertDateTimeToJavaScriptTicks(dateTime); writer.WriteValue("@" + javaScriptTicks.ToString(null, CultureInfo.InvariantCulture) + "@"); }
/// <summary> /// Writes the JSON representation of the object. /// </summary> /// <param name="writer">The <see cref="JsonWriter"/> to write to.</param> /// <param name="value">The value.</param> public override void WriteJson(JsonWriter writer, object value) { long ticks; if (value is DateTime) { DateTime dateTime = (DateTime)value; DateTime utcDateTime = dateTime.ToUniversalTime(); ticks = JavaScriptConvert.ConvertDateTimeToJavaScriptTicks(utcDateTime); } else { DateTimeOffset dateTimeOffset = (DateTimeOffset)value; DateTimeOffset utcDateTimeOffset = dateTimeOffset.ToUniversalTime(); ticks = JavaScriptConvert.ConvertDateTimeToJavaScriptTicks(utcDateTimeOffset.UtcDateTime); } writer.WriteStartConstructor("Date"); writer.WriteValue(ticks); writer.WriteEndConstructor(); }