datetime_tests

class contrib.misc.datetime_tests.DatetimeTests[source]

Bases: BahaiCalendar, TimestampUtils

BADI_COORDS = (35.69435, 51.288701, 3.5)
GMT_COORDS = (51.477928, -0.001545, 0.0)
GREG_BADI_DATES

Listy of Gregorian and Badí’ dates.

Type:

tuple

LOCAL_COORDS = (35.5894, -78.7792, -5.0)
MONTHS = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 0, 19)
TIMESTAMP_DATES = ((1, 3, 19), (1844, 3, 19), (1930, 11, 15), (1970, 1, 1), (1970, 1, 2), (2025, 3, 19), (2026, 1, 16))

List of Gregorian dates.

Type:

tuple

_subtract_tuples(t0, t1)[source]
analyze_ordinal_error_create(options)[source]

Find the errors between conversion between badi dates to JD and vice versa. This tests the BahaiCalendar.badi_date_from_jd() method. Both the jd_from_badi_date() and badi_date_from_jd() methods default to the the time zone in Tehran.

-b Also if -S and -E are used they must be used together and refer to Badi years.

analyze_ordinal_error_list(options)[source]

Find the errors between the Badi datetime ordinals and the Python date time ordinals.

-a

analyze_timestamp_errors(options)[source]

Find the errors in timestamp conversions to Badi dates. This test tries to ensures that the badidatetime.date.today() method changes date on sunset based on local time. https://www.unixtimestamp.com

-c with -A, -O, -Z, -D, and optional -U (seconds instead of minutes)

analyze_timestamp_for_today(options)[source]

See if we get close to the correct time after sunset so we can prove that sunset can be found with a timestamp.

-t -S and -E in Gregorian years

check_dates(options)[source]

Check for correct dates between different methods.

-d with -S and -E (Gregorian) -A -O -Z

test_ordinals(options)[source]

Check that the ordinals are correct.

-o with -S and -E

test_sunset_flip_invariant(options)[source]
contrib.misc.datetime_tests.find_elapse_time(start_time)[source]
contrib.misc.datetime_tests.fmt_float(value, left=4, right=4)[source]

Format one float so that it is visually centered on the decimal point.

Parameters:
  • value (float | int | str) – The number to format.

  • left (int) – Width to reserve on the left of the decimal (including any minus sign).

  • right (int) – Number of digits to show after the decimal.