コード例 #1
0
        public void Deserialize_ZuluString_DateTime()
        {
            // arrange
            DateTimeType   dateTimeType = new DateTimeType();
            DateTimeOffset dateTime     = new DateTime(2018, 6, 11, 8, 46, 14, DateTimeKind.Utc);

            // act
            DateTime deserializedValue = ((DateTimeOffset)dateTimeType
                                          .Deserialize("2018-06-11T08:46:14.000Z")).DateTime;

            // assert
            Assert.Equal(dateTime, deserializedValue);
        }
コード例 #2
0
        public void Deserialize_IsoString_DateTime()
        {
            // arrange
            DateTimeType dateTimeType = new DateTimeType();
            DateTime     dateTime     = new DateTime(2018, 6, 11, 8, 46, 14, DateTimeKind.Unspecified);

            // act
            DateTime deserializedValue = ((DateTimeOffset)dateTimeType
                                          .Deserialize("2018-06-11T08:46:14+04:00")).DateTime;

            // assert
            Assert.Equal(dateTime, deserializedValue);
            Assert.Equal(DateTimeKind.Unspecified, deserializedValue.Kind);
        }
コード例 #3
0
        public void Deserialize_ZuluString_DateTimeOffset()
        {
            // arrange
            var dateTimeType = new DateTimeType();
            var dateTime     = new DateTimeOffset(
                new DateTime(2018, 6, 11, 8, 46, 14),
                new TimeSpan(0, 0, 0));

            // act
            var deserializedValue = (DateTimeOffset)dateTimeType
                                    .Deserialize("2018-06-11T08:46:14.000Z");

            // assert
            Assert.Equal(dateTime, deserializedValue);
        }
コード例 #4
0
        public void Deserialize_IsoString_DateTimeOffset()
        {
            // arrange
            DateTimeType   dateTimeType = new DateTimeType();
            DateTimeOffset dateTime     = new DateTimeOffset(
                new DateTime(2018, 6, 11, 8, 46, 14),
                new TimeSpan(4, 0, 0));

            // act
            DateTimeOffset deserializedValue = (DateTimeOffset)dateTimeType
                                               .Deserialize("2018-06-11T08:46:14+04:00");

            // assert
            Assert.Equal(dateTime, deserializedValue);
        }