ToDateTime() public static method

Convert specified Int64 to DateTime.
public static ToDateTime ( long value ) : System.DateTime
value long /// value which is unpacked from packed message and may represent date-time value. ///
return System.DateTime
示例#1
0
        public void TestIssue43()
        {
            var expected = new DateTime(9999, 12, 31, 23, 59, 59, 999, DateTimeKind.Utc);
            var actual   = new DateTime(3155378975999999999L, DateTimeKind.Utc);

            Assert.AreEqual(
                MessagePackConvert.ToDateTime(MessagePackConvert.FromDateTime(expected)),
                MessagePackConvert.ToDateTime(MessagePackConvert.FromDateTime(actual))
                );
        }
示例#2
0
        public void TestToDateTimeRoundTrip_Minimum_IsUtcEpoc()
        {
            var offset = checked (UtcMinValue.Subtract(UtcEpoc).Ticks / TicksToMilliseconds);

            AssertIsUnixEpocDateTime(DateTime.MinValue, MessagePackConvert.ToDateTime(offset));
        }
示例#3
0
        public void TestToDateTime_MinimumMinusOne_IsUtcEpoc()
        {
            var offset = checked (UtcMinValue.Subtract(UtcEpoc).Ticks / TicksToMilliseconds - 1L);

            Assert.Throws <ArgumentOutOfRangeException>(() => MessagePackConvert.ToDateTime(offset));
        }
示例#4
0
 public void TestToDateTimeRoundTrip_Zero_IsUtcEpoc()
 {
     AssertIsUnixEpocDateTime(UtcEpoc, MessagePackConvert.ToDateTime(0));
 }
示例#5
0
 public void TestToDateTimeRoundTrip_MinusOne_IsUtcEpoc()
 {
     AssertIsUnixEpocDateTime(UtcEpoc.AddMilliseconds(-1), MessagePackConvert.ToDateTime(-1));
 }
示例#6
0
        public void TestToDateTime_Maximum_IsUtcEpoc()
        {
            var offset = checked (UtcMaxValue.Subtract(UtcEpoc).Ticks / TicksToMilliseconds);

            AssertIsUnixEpocDateTime(MessagePackConvert.ToDateTime(offset), offset);
        }
示例#7
0
 public void TestToDateTime_MinusOne_IsUtcEpoc()
 {
     AssertIsUnixEpocDateTime(MessagePackConvert.ToDateTime(-1), -1);
 }
示例#8
0
 public void TestToDateTime_Zero_IsUtcEpoc()
 {
     AssertIsUnixEpocDateTime(MessagePackConvert.ToDateTime(0), 0);
 }
示例#9
0
        public void TestToDateTime_MaximumPlusOne_IsUtcEpoc()
        {
            var offset = checked (( long )DateTime.MaxValue.Subtract(_utcEpoc).TotalMilliseconds + 1L);

            Assert.Throws <ArgumentOutOfRangeException>(() => MessagePackConvert.ToDateTime(offset));
        }
示例#10
0
        public void TestToDateTime_Minimum_IsUtcEpoc()
        {
            var offset = checked (( long )DateTime.MinValue.Subtract(_utcEpoc).TotalMilliseconds);

            AssertIsUnixEpocDateTime(MessagePackConvert.ToDateTime(offset), offset);
        }