BadiCalendar¶
- class badidatetime.tests.test_badi_calendar.TestBadiCalendar(name)[source]¶
Bases:
TestCaseSome sunrise and sunset calculations done with my SunriseSunset package. Sunrise and Sunset for 1844-03-19:
March 19, 1844 = Historic JD 2394645.11511552 (Baha’i Epoch)January, 1, 1970 = Historic JD 2440587.5 (UNIX Epoch)https://www.timeanddate.com/sun/@112931?month=3&year=1844
Alternative latitude and longitude coordinates can be found at: https://latitude.to/map/us/united-states/cities/fuquay-varina
- _classSetupFailed = False¶
- _class_cleanups = []¶
- test__badi_year_from_rd()[source]¶
Tear that the _badi_year_from_rd method returns the correct year given a Rata Die (rd).
- test__check_valid_badi_date()[source]¶
Test that the _check_valid_badi_date method returns the correct Boolean for valid and invalid dates.
- Note: The Boolean below in the data statements determines whether
or not the data is valid or invalid.
- test__day_length()[source]¶
Test that the _day_length method returns the hours, minutes, and seconds of a day.
- test__get_hms()[source]¶
Test that the _get_hms method parses the hours, minutes, and seconds correctly for either the short or long form Badi date. Test both the long and short for od the Badi Date.
- test__is_leap_year()[source]¶
Test that the _is_leap_year method returns the correct Boolean for the given year or long Badi date.
- test__trim_hms()[source]¶
Test that the _trim_hms method correctly trims the secons and minutes if zero values.
- test__utc_to_badi_time()[source]¶
Test that the _utc_to_badi_time method converts a UTC time to a Badi time. All seed values (the JD being tested) must be in UT time without zone corrections. The resultant date and time are now authoritative.
- test_badi_date_from_gregorian_date()[source]¶
Test that the badi_date_from_gregorian_date method returns the correct Badi date.
Note
All Gregorian dates are assumed to be in UT time. They get converted to the lat, lon, and zone arguments or the default. See first example below.
https://www.timeanddate.com/sun/iran/tehran?month=3&year=1844
https://www.calculatorsoup.com/calculators/time/sunrise_sunset.php
- test_badi_date_from_jd()[source]¶
Test that the badi_date_from_jd method returns the correct Badi date.
Run: ./contrib/misc/gregorian_jd_tests.py -jS<start_date> -E<end_date> to find the jd values below. It’s best to do a year at a time.
Note
All JDs are in UT1 (within 0.9 seconds of UTC) time. We check if the code changes it to the given time zone correctly.
- test_badi_date_from_timestamp()[source]¶
Test that the badi_date_from_timestamp method returns the correct Badi date with a POSIX timestamp as input.
The lat and lon at GMT is: https://www.latlong.net/place/prime-meridian-greenwich-30835.html#:~:text=Prime%20Meridian%20(Greenwich)%20Lat%20Long,%C2%B0%200’%205.5620’’%20W. https://www.unixtimestamp.com/ https://timestamp.online/ https://www.calculator.net/time-calculator.html
Check the timestamp with the standard Python datetime class. datetime.datetime.fromtimestamp(1761690180, datetime.UTC).isoformat() Julian Day == Unix timestamp / 86400 + 2440587.5 (- 2 after 1582 for Astronomically correct JD)
- test_date_from_kvymdhms()[source]¶
Test that the date_from_kvymdhms method correctly converts ((Kull-i-Shay, Váḥid, year, month, day.partial) into (Kull-i-Shay, Váḥid, year, month, day, hour, minute, second).
- test_first_day_of_ridvan_g_date()[source]¶
Test that the first_day_of_ridvan_g_date method returns Jalál 13th in any year.
- test_gregorian_date_from_badi_date()[source]¶
Test that the gregorian_date_from_badi_date method returns the correct Gregorian date.
- test_jd_from_badi_date()[source]¶
Test that the jd_from_badi_date method returns the correct jd day in UT time.
For a more complete test run: ./contrib/misc/badi_jd_tests.py -aX
- test_kvymdhms_from_b_date()[source]¶
Test that the kvymdhms_from_b_date method correctly converts ((Kull-i-Shay, Váḥid, year, month, day.partial) into (Kull-i-Shay, Váḥid, year, month, day, hour, minute, second).
- test_long_date_from_short_date()[source]¶
Test that the long_date_from_short_date method returns the correct long form Badi date.
- test_midday()[source]¶
Test that the midday method returns the middle of the Badi day in hours, minutes, and seconds or as a decimal value.
- test_short_date_from_long_date()[source]¶
Test that the short_date_from_long_date method returns the correct (year, month, day, hour, minute, seconds, us) date.
- test_timestamp_from_badi_date()[source]¶
Test that the timestamp_from_badi_date method correctly converts a Badi date to a timestamp.
- test_utc_sunset()[source]¶
Test that the utc_sunset method returns the universal time of sunset on fixed date. This results in the UTC time of sunset. See: https://gml.noaa.gov/grad/solcalc/