1# Created: 21.03.2011, 2018 rewritten for pytest
2# Copyright (C) 2011-2019, Manfred Moitzi
3# License: MIT License
4import pytest
5from datetime import datetime
6
7from ezdxf.tools.juliandate import juliandate, calendardate
8
9
10class TestJulianDate:
11    def test_1582_10_15(self):
12        assert 2299161. == pytest.approx(juliandate(datetime(1582, 10, 15)))
13
14    def test_1990_01_01(self):
15        assert 2447893. == pytest.approx(juliandate(datetime(1990, 1, 1)))
16
17    def test_2000_01_01(self):
18        assert 2451545. == pytest.approx(juliandate(datetime(2000, 1, 1)))
19
20    def test_2011_03_21(self):
21        assert 2455642.75 == pytest.approx(juliandate(datetime(2011, 3, 21, 18, 0, 0)))
22
23    def test_1999_12_31(self):
24        assert 2451544.91568287 == pytest.approx(juliandate(datetime(1999, 12, 31, 21, 58, 35)))
25
26
27class TestCalendarDate:
28    def test_1999_12_31(self):
29        check = datetime(1999, 12, 31, 21, 58, 35)
30        assert calendardate(2451544.91568288) == check
31
32    def test_2011_03_21(self):
33        check = datetime(2011, 3, 21, 18, 0, 0)
34        assert calendardate(2455642.75) == check
35