Added test and small date fix.
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
# tests/test_julian.py
|
||||
|
||||
from datetime import datetime, timezone, timedelta
|
||||
from freezegun import freeze_time
|
||||
from tools.julian import julian_date, epoch_days
|
||||
|
||||
|
||||
# Freeze time to exactly Jan 1, 2000, 12:00:00 UTC (The J2000 epoch)
|
||||
@freeze_time("2000-01-01 12:00:00", tz_offset=0)
|
||||
def test_julian_date_j2000():
|
||||
# J2000 should be exactly Julian Date 2451545.0
|
||||
jd = julian_date()
|
||||
assert jd == 2451545.0
|
||||
|
||||
|
||||
@freeze_time("2000-01-01 12:00:00", tz_offset=0)
|
||||
def test_epoch_days():
|
||||
# Since we are exactly on the epoch, days should be 0
|
||||
days = epoch_days()
|
||||
assert days == 0.0
|
||||
|
||||
|
||||
def test_julian_date_with_timezone():
|
||||
# Create a timezone-aware datetime
|
||||
tz = timezone(timedelta(hours=2))
|
||||
dt = datetime(2023, 10, 15, 12, 0, 0, tzinfo=tz)
|
||||
|
||||
jd = julian_date(dt)
|
||||
# 2023-10-15 12:00 GMT+2 is exactly 2460232.91666...
|
||||
assert round(jd, 4) == 2460232.9167
|
||||
Reference in New Issue
Block a user