示例#1
0
 /// <summary>
 /// Writes a <see cref="DateTime"/> value.
 /// </summary>
 /// <param name="value">The <see cref="DateTime"/> value to write.</param>
 public override void WriteValue(DateTime value)
 {
     InternalWriteValue(JsonToken.Date);
     value = JsonConvert.EnsureDateTime(value, DateTimeZoneHandling);
     _writer.Write(_quoteChar);
     JsonConvert.WriteDateTimeString(_writer, value, DateFormatHandling, DateFormatString, Culture);
     _writer.Write(_quoteChar);
 }
示例#2
0
        public static string ToString(DateTime value, DateFormatHandling format, DateTimeZoneHandling timeZoneHandling)
        {
            DateTime d = JsonConvert.EnsureDateTime(value, timeZoneHandling);

            using (StringWriter stringWriter = StringUtils.CreateStringWriter(64))
            {
                JsonConvert.WriteDateTimeString((TextWriter)stringWriter, d, DateTimeUtils.GetUtcOffset(d), d.Kind, format);
                return(stringWriter.ToString());
            }
        }
        public static string ToString(DateTimeOffset value)
        {
            string str;

            using (StringWriter stringWriter = StringUtils.CreateStringWriter(64))
            {
                JsonConvert.WriteDateTimeString(stringWriter, value.UtcDateTime, value.Offset, DateTimeKind.Local);
                str = stringWriter.ToString();
            }
            return(str);
        }
        public static string ToString(DateTime value)
        {
            string str;

            using (StringWriter stringWriter = StringUtils.CreateStringWriter(64))
            {
                JsonConvert.WriteDateTimeString(stringWriter, value, JsonConvert.GetUtcOffset(value), value.Kind);
                str = stringWriter.ToString();
            }
            return(str);
        }
        public static string ToString(DateTimeOffset value)
        {
            string result;

            using (StringWriter stringWriter = StringUtils.CreateStringWriter(64))
            {
                JsonConvert.WriteDateTimeString(stringWriter, value.get_UtcDateTime(), value.get_Offset(), 2);
                result = stringWriter.ToString();
            }
            return(result);
        }
        public static string ToString(DateTime value)
        {
            string result;

            using (StringWriter stringWriter = StringUtils.CreateStringWriter(64))
            {
                JsonConvert.WriteDateTimeString(stringWriter, value, JsonConvert.GetUtcOffset(value), value.get_Kind());
                result = stringWriter.ToString();
            }
            return(result);
        }
 /// <summary>
 /// Writes a <see cref="DateTime"/> value.
 /// </summary>
 /// <param name="value">The <see cref="DateTime"/> value to write.</param>
 public override void WriteValue(DateTime value)
 {
     base.WriteValue(value);
     JsonConvert.WriteDateTimeString(_writer, value, DateFormatHandling);
 }
 internal static void WriteDateTimeString(TextWriter writer, DateTime value)
 {
     JsonConvert.WriteDateTimeString(writer, value, JsonConvert.GetUtcOffset(value), value.Kind);
 }
 public override void WriteValue(DateTime value)
 {
     base.WriteValue(value);
     JsonConvert.WriteDateTimeString(this._writer, value);
 }
示例#10
0
 public override void WriteValue(DateTime value)
 {
     base.WriteValue(value);
     value = JsonConvert.EnsureDateTime(value, this.DateTimeZoneHandling);
     JsonConvert.WriteDateTimeString(this._writer, value, this.DateFormatHandling);
 }
示例#11
0
 internal static void WriteDateTimeString(TextWriter writer, DateTime value, DateFormatHandling format)
 {
     JsonConvert.WriteDateTimeString(writer, value, DateTimeUtils.GetUtcOffset(value), value.Kind, format);
 }