Beispiel #1
0
    public static void TestRoundtripUnixTimes()
    {
        foreach (var test in s_testTimes)
        {
            // Roundtrip Unix time in milliseconds
            DateTimeOffset dateTime = DateTimeOffset.FromUnixTimeMilliseconds(test.UnixTimeMilliseconds);
            TestToUnixTimeMilliseconds(TestTime.FromMilliseconds(dateTime, test.UnixTimeMilliseconds));

            // Roundtrip Unix time in seconds
            dateTime = DateTimeOffset.FromUnixTimeSeconds(test.UnixTimeSeconds);
            TestToUnixTimeSeconds(TestTime.FromSeconds(dateTime, test.UnixTimeSeconds));
        }
    }
Beispiel #2
0
    public static void TestRoundtripDateTimes()
    {
        foreach (var test in s_testTimes)
        {
            // Roundtrip through Unix time in milliseconds
            long unixTimeMilliseconds = test.DateTimeOffset.ToUnixTimeMilliseconds();
            TestFromUnixTimeMilliseconds(TestTime.FromMilliseconds(test.DateTimeOffset, unixTimeMilliseconds));

            // Roundtrip through Unix time in seconds
            long unixTimeSeconds = test.DateTimeOffset.ToUnixTimeSeconds();
            TestFromUnixTimeSeconds(TestTime.FromSeconds(test.DateTimeOffset, unixTimeSeconds));
        }
    }
Beispiel #3
0
        public static IEnumerable <object[]> QuaranTime_TestData()
        {
            yield return(new object[] { TestTime.FromMilliseconds(DateTimeOffset.MinValue, -63720270000000) });

            yield return(new object[] { TestTime.FromMilliseconds(DateTimeOffset.MaxValue, 251817627599999) });

            yield return(new object[] { TestTime.FromMilliseconds(new DateTimeOffset(2020, 3, 20, 0, 0, 0, TimeSpan.FromHours(-3)), 0) });

            yield return(new object[] { TestTime.FromMilliseconds(new DateTimeOffset(2014, 6, 13, 17, 21, 50, TimeSpan.Zero), -181993090000) });

            yield return(new object[] { TestTime.FromMilliseconds(new DateTimeOffset(2830, 12, 15, 1, 23, 45, TimeSpan.Zero), 25584416625000) });

            yield return(new object[] { TestTime.FromMilliseconds(new DateTimeOffset(2830, 12, 15, 1, 23, 45, 399, TimeSpan.Zero), 25584416625399) });

            yield return(new object[] { TestTime.FromMilliseconds(new DateTimeOffset(9999, 12, 30, 23, 24, 25, TimeSpan.Zero), 251817539065000) });

            yield return(new object[] { TestTime.FromMilliseconds(new DateTimeOffset(1907, 7, 7, 7, 7, 7, TimeSpan.Zero), -3556641173000) });

            yield return(new object[] { TestTime.FromMilliseconds(new DateTimeOffset(1907, 7, 7, 7, 7, 7, 1, TimeSpan.Zero), -3556641172999) });

            yield return(new object[] { TestTime.FromMilliseconds(new DateTimeOffset(1907, 7, 7, 7, 7, 7, 777, TimeSpan.Zero), -3556641172223) });

            yield return(new object[] { TestTime.FromMilliseconds(new DateTimeOffset(601636288270011234, TimeSpan.Zero), -3556641172999) });
        }
Beispiel #4
0
    private static IEnumerable <object[]> UnixTime_TestData()
    {
        yield return(new object[] { TestTime.FromMilliseconds(DateTimeOffset.MinValue, -62135596800000) });

        yield return(new object[] { TestTime.FromMilliseconds(DateTimeOffset.MaxValue, 253402300799999) });

        yield return(new object[] { TestTime.FromMilliseconds(new DateTimeOffset(1970, 1, 1, 0, 0, 0, TimeSpan.Zero), 0) });

        yield return(new object[] { TestTime.FromMilliseconds(new DateTimeOffset(2014, 6, 13, 17, 21, 50, TimeSpan.Zero), 1402680110000) });

        yield return(new object[] { TestTime.FromMilliseconds(new DateTimeOffset(2830, 12, 15, 1, 23, 45, TimeSpan.Zero), 27169089825000) });

        yield return(new object[] { TestTime.FromMilliseconds(new DateTimeOffset(2830, 12, 15, 1, 23, 45, 399, TimeSpan.Zero), 27169089825399) });

        yield return(new object[] { TestTime.FromMilliseconds(new DateTimeOffset(9999, 12, 30, 23, 24, 25, TimeSpan.Zero), 253402212265000) });

        yield return(new object[] { TestTime.FromMilliseconds(new DateTimeOffset(1907, 7, 7, 7, 7, 7, TimeSpan.Zero), -1971967973000) });

        yield return(new object[] { TestTime.FromMilliseconds(new DateTimeOffset(1907, 7, 7, 7, 7, 7, 1, TimeSpan.Zero), -1971967972999) });

        yield return(new object[] { TestTime.FromMilliseconds(new DateTimeOffset(1907, 7, 7, 7, 7, 7, 777, TimeSpan.Zero), -1971967972223) });

        yield return(new object[] { TestTime.FromMilliseconds(new DateTimeOffset(601636288270011234, TimeSpan.Zero), -1971967972999) });
    }
Beispiel #5
0
        public static void FromQuaranTimeMilliseconds_RoundTrip(TestTime test)
        {
            DateTimeOffset dateTime = QuaranTime.FromQuaranTimeMilliseconds(test.QuaranTimeMilliseconds);

            ToQuaranTimeMilliseconds(TestTime.FromMilliseconds(dateTime, test.QuaranTimeMilliseconds));
        }
Beispiel #6
0
        public static void ToQuaranTimeMilliseconds_RoundTrip(TestTime test)
        {
            long quaranTimeMilliseconds = test.DateTimeOffset.ToQuaranTimeMilliseconds();

            FromQuaranTimeMilliseconds(TestTime.FromMilliseconds(test.DateTimeOffset, quaranTimeMilliseconds));
        }
Beispiel #7
0
    public static void TestFromUnixTimeMilliseconds_RoundTrip(TestTime test)
    {
        DateTimeOffset dateTime = DateTimeOffset.FromUnixTimeMilliseconds(test.UnixTimeMilliseconds);

        TestToUnixTimeMilliseconds(TestTime.FromMilliseconds(dateTime, test.UnixTimeMilliseconds));
    }
Beispiel #8
0
    public static void TesToUnixTimeMilliseconds_RountTrip(TestTime test)
    {
        long unixTimeMilliseconds = test.DateTimeOffset.ToUnixTimeMilliseconds();

        TestFromUnixTimeMilliseconds(TestTime.FromMilliseconds(test.DateTimeOffset, unixTimeMilliseconds));
    }