Beispiel #1
0
        public void TestDoesDayHaveLeapSecond()
        {
            LeapSeconds leapSeconds = new LeapSeconds();

            Assert.IsTrue(leapSeconds.DoesDayHaveLeapSecond(2443509));
            Assert.IsFalse(leapSeconds.DoesDayHaveLeapSecond(2443510));
        }
Beispiel #2
0
        public void TestDoesDayHaveLeapSecond()
        {
            LeapSeconds leapSeconds = new LeapSeconds();

            Assert.IsTrue(leapSeconds.DoesDayHaveLeapSecond(2443509));
            Assert.IsFalse(leapSeconds.DoesDayHaveLeapSecond(2443510));
        }
Beispiel #3
0
        public void TestGetOffsetTai()
        {
            JulianDate  date        = new JulianDate(2453736, 43222.0, TimeStandard.InternationalAtomicTime);
            LeapSeconds leapSeconds = new LeapSeconds();

            Assert.AreEqual(32, leapSeconds.GetTaiMinusUtc(date));
        }
Beispiel #4
0
        public void TestLeapSecondCount()
        {
            LeapSeconds leapSeconds = new LeapSeconds();

            JulianDate utc = new JulianDate(new GregorianDate(1998, 4, 1, 12, 0, 0));
            JulianDate tai = utc.ToTimeStandard(TimeStandard.InternationalAtomicTime);
            Assert.AreEqual(31, leapSeconds.GetTaiMinusUtc(utc));
            Assert.AreEqual(31, leapSeconds.GetTaiMinusUtc(tai));
        }
Beispiel #5
0
        public void TestLeapSecondCount()
        {
            LeapSeconds leapSeconds = new LeapSeconds();

            JulianDate utc = new GregorianDate(1998, 4, 1, 12, 0, 0).ToJulianDate();
            JulianDate tai = utc.ToTimeStandard(TimeStandard.InternationalAtomicTime);
            Assert.AreEqual(31, leapSeconds.GetTaiMinusUtc(utc));
            Assert.AreEqual(31, leapSeconds.GetTaiMinusUtc(tai));
        }
Beispiel #6
0
        public void TestGetLeapSecondsForDateTaiUtc()
        {
            LeapSeconds leapSeconds = new LeapSeconds();

            JulianDate tai = new JulianDate(2447162.5, TimeStandard.InternationalAtomicTime);
            JulianDate utc = tai.ToTimeStandard(TimeStandard.CoordinatedUniversalTime);
            Assert.AreEqual(leapSeconds.GetTaiMinusUtc(tai), leapSeconds.GetTaiMinusUtc(utc));

            utc = new JulianDate(2445151.5, TimeStandard.CoordinatedUniversalTime);
            tai = utc.ToTimeStandard(TimeStandard.InternationalAtomicTime);
            Assert.AreEqual(leapSeconds.GetTaiMinusUtc(utc), leapSeconds.GetTaiMinusUtc(tai));
        }
Beispiel #7
0
        public void TestGetLeapSecondsForDateTaiUtc()
        {
            LeapSeconds leapSeconds = new LeapSeconds();

            JulianDate tai = new JulianDate(2447162.5, TimeStandard.InternationalAtomicTime);
            JulianDate utc = tai.ToTimeStandard(TimeStandard.CoordinatedUniversalTime);
            Assert.AreEqual(leapSeconds.GetTaiMinusUtc(tai), leapSeconds.GetTaiMinusUtc(utc));

            utc = new JulianDate(2445151.5, TimeStandard.CoordinatedUniversalTime);
            tai = utc.ToTimeStandard(TimeStandard.InternationalAtomicTime);
            Assert.AreEqual(leapSeconds.GetTaiMinusUtc(utc), leapSeconds.GetTaiMinusUtc(tai));
        }
Beispiel #8
0
        public void TestExtremes()
        {
            LeapSeconds leapSeconds = new LeapSeconds();

            JulianDate epochBefore = new JulianDate(2440000.5, TimeStandard.InternationalAtomicTime);
            Assert.AreEqual(10, leapSeconds.GetTaiMinusUtc(epochBefore));
            epochBefore = new JulianDate(epochBefore.Day, epochBefore.SecondsOfDay, TimeStandard.CoordinatedUniversalTime);
            Assert.AreEqual(10, leapSeconds.GetTaiMinusUtc(epochBefore));

            JulianDate epochAfter = new JulianDate(2453770.5, TimeStandard.InternationalAtomicTime);
            Assert.AreEqual(33, leapSeconds.GetTaiMinusUtc(epochAfter));
            epochAfter = new JulianDate(epochAfter.Day, epochAfter.SecondsOfDay, TimeStandard.CoordinatedUniversalTime);
            Assert.AreEqual(33, leapSeconds.GetTaiMinusUtc(epochAfter));
        }
Beispiel #9
0
        public void TestExtremes()
        {
            LeapSeconds leapSeconds = new LeapSeconds();

            JulianDate epochBefore = new JulianDate(2440000.5, TimeStandard.InternationalAtomicTime);
            Assert.AreEqual(10, leapSeconds.GetTaiMinusUtc(epochBefore));
            epochBefore = new JulianDate(epochBefore.Day, epochBefore.SecondsOfDay, TimeStandard.CoordinatedUniversalTime);
            Assert.AreEqual(10, leapSeconds.GetTaiMinusUtc(epochBefore));

            JulianDate epochAfter = new JulianDate(2453770.5, TimeStandard.InternationalAtomicTime);
            Assert.AreEqual(33, leapSeconds.GetTaiMinusUtc(epochAfter));
            epochAfter = new JulianDate(epochAfter.Day, epochAfter.SecondsOfDay, TimeStandard.CoordinatedUniversalTime);
            Assert.AreEqual(33, leapSeconds.GetTaiMinusUtc(epochAfter));
        }
Beispiel #10
0
        public void TestTaiToUtcNearLeapSecond()
        {
            LeapSeconds leapSeconds = new LeapSeconds();
            LeapSeconds.Instance = leapSeconds;

            JulianDate momentOfLeapSecond = new JulianDate(2453736, 43232.0, TimeStandard.InternationalAtomicTime);
            JulianDate before = momentOfLeapSecond - Duration.FromSeconds(1.0);
            JulianDate after = momentOfLeapSecond + Duration.FromSeconds(1.0);

            JulianDate beforeUtc = before.ToTimeStandard(TimeStandard.CoordinatedUniversalTime);
            JulianDate afterUtc = after.ToTimeStandard(TimeStandard.CoordinatedUniversalTime);

            Assert.AreNotEqual(beforeUtc, afterUtc);
        }
Beispiel #11
0
        public void TestNegativeLeapSecond()
        {
            List <LeapSecond> newList = new List <LeapSecond>();

            newList.Add(new LeapSecond(2451545.0, 11));
            newList.Add(new LeapSecond(2451555.0, 12));
            newList.Add(new LeapSecond(2451565.0, 11));
            newList.Add(new LeapSecond(2451575.0, 10));

            LeapSeconds leapSeconds = new LeapSeconds(newList);

            Assert.AreEqual(11, leapSeconds.GetTaiMinusUtc(new JulianDate(2451545.5, TimeStandard.CoordinatedUniversalTime)));
            Assert.AreEqual(12, leapSeconds.GetTaiMinusUtc(new JulianDate(2451555.5, TimeStandard.CoordinatedUniversalTime)));
            Assert.AreEqual(11, leapSeconds.GetTaiMinusUtc(new JulianDate(2451565.5, TimeStandard.CoordinatedUniversalTime)));
            Assert.AreEqual(10, leapSeconds.GetTaiMinusUtc(new JulianDate(2451575.5, TimeStandard.CoordinatedUniversalTime)));
        }
Beispiel #12
0
        public void TestUtcAddNotStuckAtLeapSecond()
        {
            LeapSeconds leapSeconds = new LeapSeconds();
            LeapSeconds.Instance = leapSeconds;

            JulianDate date = new JulianDate(2453736, 43198.0, TimeStandard.CoordinatedUniversalTime);
            JulianDate after = new JulianDate(2453736, 43202.0, TimeStandard.CoordinatedUniversalTime);
            int i;
            for (i = 0; i < 100; ++i)
            {
                date += Duration.FromSeconds(0.1);
                if (date > after)
                {
                    break;
                }
            }

            // 5 second difference, so 50 additions of a tenth of a second each
            Assert.AreEqual(50, i);
        }
Beispiel #13
0
        public void TestNegativeLeapSecond()
        {
            List<LeapSecond> newList = new List<LeapSecond>();
            newList.Add(new LeapSecond(2451545.0, 11));
            newList.Add(new LeapSecond(2451555.0, 12));
            newList.Add(new LeapSecond(2451565.0, 11));
            newList.Add(new LeapSecond(2451575.0, 10));

            LeapSeconds leapSeconds = new LeapSeconds(newList);

            Assert.AreEqual(11, leapSeconds.GetTaiMinusUtc(new JulianDate(2451545.5, TimeStandard.CoordinatedUniversalTime)));
            Assert.AreEqual(12, leapSeconds.GetTaiMinusUtc(new JulianDate(2451555.5, TimeStandard.CoordinatedUniversalTime)));
            Assert.AreEqual(11, leapSeconds.GetTaiMinusUtc(new JulianDate(2451565.5, TimeStandard.CoordinatedUniversalTime)));
            Assert.AreEqual(10, leapSeconds.GetTaiMinusUtc(new JulianDate(2451575.5, TimeStandard.CoordinatedUniversalTime)));
        }
Beispiel #14
0
        public void TestUtcAddNotStuckAtLeapSecond()
        {
            LeapSeconds leapSeconds = new LeapSeconds();
            LeapSeconds.Instance = leapSeconds;

            JulianDate date = new JulianDate(2453736, 43198.0, TimeStandard.CoordinatedUniversalTime);
            JulianDate after = new JulianDate(2453736, 43202.0, TimeStandard.CoordinatedUniversalTime);
            int i;
            for (i = 0; i < 100; ++i)
            {
                date += Duration.FromSeconds(0.1);
                if (date > after)
                {
                    break;
                }
            }

            //5 second difference, so 50 additions of a tenth of a second each
            Assert.AreEqual(50, i);
        }
Beispiel #15
0
        public void TestTaiToUtcNearLeapSecond()
        {
            LeapSeconds leapSeconds = new LeapSeconds();
            LeapSeconds.Instance = leapSeconds;

            JulianDate momentOfLeapSecond = new JulianDate(2453736, 43232.0, TimeStandard.InternationalAtomicTime);
            JulianDate before = momentOfLeapSecond - Duration.FromSeconds(1.0);
            JulianDate after = momentOfLeapSecond + Duration.FromSeconds(1.0);

            JulianDate beforeUtc = before.ToTimeStandard(TimeStandard.CoordinatedUniversalTime);
            JulianDate afterUtc = after.ToTimeStandard(TimeStandard.CoordinatedUniversalTime);

            Assert.AreNotEqual(beforeUtc, afterUtc);
        }
Beispiel #16
0
 public void TestGetOffsetTai()
 {
     JulianDate date = new JulianDate(2453736, 43222.0, TimeStandard.InternationalAtomicTime);
     LeapSeconds leapSeconds = new LeapSeconds();
     Assert.AreEqual(32, leapSeconds.GetTaiMinusUtc(date));
 }