コード例 #1
0
        public void ISO8601Dates_WithPositiveOffset()
        {
            var date = new DateTime(2001, 12, 14, 18, 15, 12, DateTimeKind.Local);

            var sb = new StringBuilder();

            using (var wri = new StringWriter(sb))
                JW.EncodeDateTime(wri, date, utcOffset: TimeSpan.FromHours(3.5));

            Console.WriteLine(sb);

            Aver.AreEqual("\"2001-12-14T18:15:12+03:30\"".Args(), sb.ToString());
        }
コード例 #2
0
        public void ISO8601Dates_Utc()
        {
            var date = new DateTime(2001, 12, 14, 18, 15, 12, DateTimeKind.Utc);

            var sb = new StringBuilder();

            using (var wri = new StringWriter(sb))
                JW.EncodeDateTime(wri, date);

            Console.WriteLine(sb);

            Aver.AreEqual("\"2001-12-14T18:15:12Z\"", sb.ToString());
        }
コード例 #3
0
        public void ISO8601Dates_1()
        {
            var date = new DateTime(1, 1, 1, 2, 2, 3, DateTimeKind.Utc);

            var sb = new StringBuilder();

            using (var wri = new StringWriter(sb))
                JW.EncodeDateTime(wri, date);

            Console.WriteLine(sb);

            Aver.AreEqual("\"0001-01-01T02:02:03Z\"", sb.ToString());
        }
コード例 #4
0
        public void ISO8601Dates_2_ms()
        {
            var date = new DateTime(1, 1, 1, 2, 2, 3, 45, DateTimeKind.Utc);

            var sb = new StringBuilder();

            using (var wri = new StringWriter(sb))
                JW.EncodeDateTime(wri, date);

            sb.See();

            Aver.AreEqual("\"0001-01-01T02:02:03.045Z\"", sb.ToString());
        }
コード例 #5
0
        public void ISO8601Dates_WithNoOffset()
        {
            var date = new DateTime(2001, 12, 14, 18, 15, 12, DateTimeKind.Local);

            var sb = new StringBuilder();

            using (var wri = new StringWriter(sb))
                JW.EncodeDateTime(wri, date);

            Console.WriteLine(sb.ToString().Trim('"'));

            var got = DateTime.Parse(sb.ToString().Trim('"'));

            Console.WriteLine("got: {0}", got);

            Aver.AreEqual(date, got);
        }