datetime module

class badidatetime.tests.test_datetime.NoneTimeZone[source]

Bases: tzinfo

Creates a Timezone which defaults to None for the utcoffset, tzname, and dst methods.

dst(dt)[source]

datetime -> DST offset as timedelta positive east of UTC.

set_dst(value)[source]
set_tzname(value)[source]
set_utcoffset(value)[source]
tzname(dt)[source]

datetime -> string name of time zone.

utcoffset(dt)[source]

datetime -> timedelta showing offset from UTC, negative values indicating West of UTC

class badidatetime.tests.test_datetime.TestBadiDatetimeFunctions(name)[source]

Bases: TestCase

_classSetupFailed = False
_class_cleanups = []
setUp()[source]

Hook method for setting up the test fixture before exercising it.

classmethod setUpClass()[source]

Hook method for setting up class fixture before running tests in the class.

test__check_offset()[source]

Test that the _check_utc_offset function returns the correct result.

test__check_tzinfo_arg()[source]

Test that the _check_tzinfo_arg function returns the correct result.

test__check_tzname()[source]

Test that the _check_tzname function raises a TypeError is the name argument is not None or a string.

test__cmp()[source]

Test that the _cmp method returns the the correct value for the caparison.

test__cmperror()[source]

Test that the _cmperror

test__divide_and_round()[source]

Test that the _divide_and_round function returns the correct result.

test__format_offset()[source]

Test that the _format_offset returns the correct result.

test__format_time()[source]

Test that the _format_time function returns the correct result.

test__get_class_module()[source]

Test that the _get_class_module function returns the correct module name.

test__module_name()[source]

Test that the _module_name function returns the module path without the base directory.

class badidatetime.tests.test_datetime.TestBadiDatetime_TZWithCoords(name)[source]

Bases: TestCase

_classSetupFailed = False
_class_cleanups = []
test___new__()[source]

Test that the __new__ method returns a valid TZWithCoords object.

test___reduce__()[source]

Test that the __reduce__ method returns a correct pickle object.

test___str__()[source]

Test that the __str__ method return the correct string.

test_coordinates()[source]

Test that the coordinates property returns the coordinates.

test_dst()[source]

Test that the dst method returns the dst (daylight-savings-time).

class badidatetime.tests.test_datetime.TestBadiDatetime__IsoCalendarDate(name)[source]

Bases: TestCase

_classSetupFailed = False
_class_cleanups = []
test___reduce__()[source]

Test that the __reduce__ method works for both short and long form Badi dates.

test___repr__()[source]

Test that the __repr__ returns the expected formatted text.

test_week()[source]

Test that the week property returns the week.

test_weekday()[source]

Test that the weekday property returns the weekday.

test_year()[source]

Test that the year property returns the year.

class badidatetime.tests.test_datetime.TestBadiDatetime__module__(name)[source]

Bases: TestCase

Test that all classes that are defined in the datetime.py module have their internal __module__ changed to badidatetime.

_classSetupFailed = False
_class_cleanups = []
test_date()[source]
test_datetime()[source]
test_time()[source]
test_timedelta()[source]

The ‘timedelta` class is borrowed from the Python datetime package.

test_timezone()[source]
test_tzinfo()[source]

The ‘tzinfo` class is borrowed from the Python datetime package.

class badidatetime.tests.test_datetime.TestBadiDatetime_date(name)[source]

Bases: TestCase

_classSetupFailed = False
_class_cleanups = []
classmethod setUpClass()[source]

Hook method for setting up class fixture before running tests in the class.

test___add__()[source]

Test that the __add__ method can correctly add a date to a timedelta.

test___eq__()[source]

Test that the __eq__ method returns True if equal and False if not equal.

test___format__()[source]

Test that the __format__ method returns a correctly formatted string.

test___ge__()[source]

Test that the __ge__ method returns True if greater than or equal and False if not greater than or equal.

test___gt__()[source]

Test that the __gt__ method returns True if greater than and False if not greater than.

test___hash__()[source]

Test that the __hash__ method returns a valid hash for both short and long form dates.

test___le__()[source]

Test that the __le__ method returns True if less than or equal and False if not less than or equal.

test___lt__()[source]

Test that the __lt__ method returns True if less than and False if not less than.

test___new__()[source]

Test that the __new__ method creates an instance from both a pickle object and a normal instantiation.

test___reduce__()[source]

Test that the __reduce__ method works for both short and long form Badi dates.

test___repr__()[source]

Test that the __repr__ returns the expected formatted text.

test___setstate()[source]

Test that the __setstate method sets the date properly.

test___str__()[source]

Test that the __str__ method returns the ISO formated version of the date represented by the class object.

test___sub__()[source]

Test that the __sub__ method returns the correct results of a timedelta object subtracted from a date object.

test__cmp()[source]

Test that the _cmp method returns 1 if the two dates are equal, +1 if the current date is greater than the test date, and -1 if the inverse.

test__getstate()[source]

Test that the _getstate method returns the state of the class.

test__is_pickle_data()[source]

Test that the _is_pickle_data classmethod returns the correct results depending on the incoming data.

test__short_from_long_form()[source]

Test that the _short_from_long_form method returns the short form Badi date.

test_ctime()[source]

Test that the ctime method creates a string indicating the date.

All days before 1752-09-14 in the Gregorian Calendar will seem wrong when compaired to the Badi Calendar in UK and the US. This is when The Gregorian Calendar was adopted and compinsated 11 days.

test_day()[source]

Test that the day property returns the day value.

test_fromisocalendar()[source]

Test that the fromisocalendar class method creates a date instance from an ISO calendar date.

test_fromisoformat()[source]

Test that the fromisoformat class method creates a date instance from an ISO formatted string.

test_fromordinal()[source]

Test that the fromordinal class method creates a date instance from a date ordinal number.

local coords (35.5894, -78.7792, -5.0)

test_fromtimestamp_local()[source]

Test that the fromtimestamp class method creates an instance of date from a POSIX timestamp for local time.

test_fromtimestamp_tehran()[source]

Test that the fromtimestamp class method creates an instance of date from a POSIX timestamp for Tehran time.

test_fromtimestamp_utc()[source]

Test that the fromtimestamp class method creates an instance of date from a POSIX timestamp for UTC time.

test_is_short()[source]

Test that the is_short property properly indicates if the Badi date is in the short or long form.

test_isocalendar()[source]

Test that the isocalendar method the correct ISO Calendar tuple.

test_isoformat()[source]

Test that the isoformat method return the ISO formated version of the date represented by this class.

test_isoweekday()[source]

Test that the weekday method returns the correct weekday number.

test_kull_i_shay()[source]

Test that the kull_i_shay property returns the kull_i_shay value.

test_month()[source]

Test that the month property returns the month value.

test_replace()[source]

Test that the replace method returns a new date object with the replaced values.

test_strftime(mock_property)[source]

Test that the strftime method returns a formatted date time string. We need to mock the date_format property because everywhere is not here.

test_timetuple()[source]

Test that the timetuple returns the correct long or short form object.

test_today()[source]

Test that the today class method creates an instance of date for today.

test_toordinal()[source]

Test that the toordinal method returns a proleptic Badi ordinal.

test_vahid()[source]

Test that the vahid property returns the vahid value.

test_weekday()[source]

Test that the weekday method returns the correct weekday number.

test_year()[source]

Test that the year property returns the year value.

class badidatetime.tests.test_datetime.TestBadiDatetime_datetime(name)[source]

Bases: TestCase

_classSetupFailed = False
_class_cleanups = []
_get_time(time)[source]
classmethod setUpClass()[source]

Hook method for setting up class fixture before running tests in the class.

test___add__()[source]

Test that the __add__ method can correctly add a datetime to a timedelta.

test___eq__()[source]

Test that the __eq__ method returns True if equal and False if not equal.

test___ge__()[source]

Test that the __ge__ method returns True if greater than or equal and False if not greater than or equal.

test___gt__()[source]

Test that the __gt__ method returns True if greater than and False if not greater than.

test___hash__()[source]

Test that the __hash__ method returns a valid hash for both short and long form datetimes.

test___le__()[source]

Test that the __le__ method returns True if less than or equal and False if not less than or equal.

test___lt__()[source]

Test that the __lt__ method returns True if less than and False if not less than.

test___new__()[source]

Test that the __new__ method creates an instance from both a pickle object and a normal instantiation.

test___reduce_ex__()[source]

Test that the __reduce_ex__ method creates the correct pickle value for protocol 3.

test___repr__()[source]

Test that the __repr__ method returns a string of the object.

test___setstate()[source]

Test that the __setstate method sets the datetime properly.

test___sub__()[source]

Test that the __sub__ method returns the correct results of a timedelta object subtracted from a datetime object.

test__cmp()[source]

Test that the _cmp method returns 1 if the two dates are equal, +1 if the current date is greater than the test date, and -1 if the inverse.

test__dt_str_conversion()[source]

Test that the _dt_str_conversion method returns a string of the object.

test__fromtimestamp_gmt()[source]

Test that the _fromtimestamp classmethod creates an instance of datetime.

Note

The tests marked ‘Latitude and Longitude dependent’ will break if datetime.LOCAL_COORD is not patched when run in a different locale.

test__fromtimestamp_local()[source]

Test that the _fromtimestamp classmethod creates an instance of datetime.

Note

The tests marked ‘Latitude and Longitude dependent’ will break if datetime.LOCAL_COORD is not patched when run in a different locale.

test__getstate()[source]

Test that the _getstate method returns the correct state for pickling.

test__is_pickle_data()[source]

Test that the _is_pickle_data classmethod returns the correct results depending on the incoming data.

test__local_timezone()[source]

Test that the _local_timezone method returns the local time offset.

test__mktime_gmt()[source]

Test that the _mktime method finds the POSIX time in seconds for local GMT time. All tests below will only work with GMT set at the local time set in the above patch. https://www.epochconverter.com/timezones https://www.suntoday.org/sunrise-sunset/

test__mktime_local()[source]

Test that the _mktime method finds the POSIX time in seconds for local time EST. All tests below will only work with the local time set in the above patch.

test__mktime_tehran()[source]

Test that the _mktime method finds the POSIX time in seconds for local time in Terhan. All tests below will only work with Terhan set as the local time set in the above patch. https://www.epochconverter.io/timezones-converter

test__timetuple()[source]

Test that the _timetuple method returns a timetuple object.

test_astimezone()[source]

Test that the astimezone method returns a datetime object with a replaced the timezone tzinfo object.

test_combine()[source]

Test that the combine classmethod creates an instance of datetime from an instance of a date and time object.

test_ctime()[source]

Test that the ctime method creates a string indicating the date and time.

All days before 1752-09-14 in the Gregorian Calendar will seem wrong when compaired to the Badi Calendar in UK and the US. This is when The Gregorian Calendar was adopted and compinsated 11 days.

test_date()[source]

Test that thedate method returns a date object with the same date as the originating datetime object.

test_dst()[source]

Test that the dst method returns the daylight savings time associated with the datetime object.

test_fold()[source]

Test that the fold returns the correct value.

test_fromisoformat()[source]

Test that the fromisoformat classmethod creates an instance of datetime.

test_fromtimestamp()[source]

Test that the fromtimestamp classmethod creates a correct instance of datetime with a -5.0 time zone.

Note

The tests marked ‘Latitude and Longitude dependent’ will break if datetime.LOCAL_COORD is not patched when run in a different locale.

test_hour()[source]

Test that the hour property returns the correct value.

test_isoformat()[source]

Test that the isoformat method returns an ISO formatted date and time.

test_microsecond()[source]

Test that the microsecond returns the correct value.

test_minute()[source]

Test that the minute returns the correct value.

test_now()[source]

Test that the now classmethod creates an instance of datetime. It is not possible to test actual dates and time as they will change every second.

test_replace()[source]

Test that the replace method a new datetime object with the replaced values.

test_second()[source]

Test that the second returns the correct value.

test_strptime()[source]

Test that the strptime method parses a date from a string and returns a datetime class object.

test_time()[source]

Test that the time method a time object with the same time as the originating datetime object.

test_timestamp()[source]

Test that the timestamp method returns either the POSIX time for local or for the timezone provided.

https://www.unixtimestamp.com https://www.epochconverter.com

test_timetuple()[source]

Test that the timetuple method returns either a short or long form timetuple.

test_timetz()[source]

Test that the timetz method a time object with the same time and tzinfo as the originating datetime object.

test_tzinfo()[source]

Test that the tzinfo returns the correct value.

test_tzname()[source]

Test that the tzname method returns the timezone associated with the datetime object.

test_utcoffset()[source]

Test that the utcoffset method returns a timedelta object relative to the UTC time zone..

test_utctimetuple()[source]

Test that the utctimetuple method returns a timetuple object.

class badidatetime.tests.test_datetime.TestBadiDatetime_time(name)[source]

Bases: TestCase

_classSetupFailed = False
_class_cleanups = []
classmethod setUpClass()[source]

Hook method for setting up class fixture before running tests in the class.

test___eq__()[source]

Test that the __eq__ method returns True if equal and False if not equal.

test___format__()[source]

Test that the __format__ method returns a correctly formatting string.

test___ge__()[source]

Test that the __ge__ method returns True if greater than or equal and False if not greater than or equal.

test___gt__()[source]

Test that the __gt__ method returns True if greater than and False if not greater than.

test___hash__()[source]

Test that the __hash__ method returns the proper hash of the class.

test___le__()[source]

Test that the __le__ method returns True if less than or equal and False if not less than or equal.

test___lt__()[source]

Test that the __lt__ method returns True if less than and False if not less than.

test___new__()[source]

Test that the __new__ method creates an instance from both a pickle object and a normal instantiation.

test___reduce_ex__()[source]

Test that the __reduce_ex__ method creates the correct pickle value for protocol 3.

test___repr__()[source]

Test that the __repr__ method returns the correct string.

test___setstate()[source]

Test that the __setstate method sets the correct state for pickeling.

test__cmp()[source]

Test that the _cmp method returns 1 if the two times are equal, +1 if the current time is greater than the test time, and -1 if the inverse.

test__getstate()[source]

Test that the _getstate method returns the state of the class.

test__tzstr()[source]

Test that the _tzstr method returns a formatted timezone offset.

test_badioffset()[source]

Test that the badioffset

test_dst()[source]

Test that the dst method returns either 0 or 1 if DST is in effect.

test_fold()[source]

Test that the fold returns the correct value.

test_fromisoformat()[source]

Test that the fromisoformat classmethod returns a correctly formatted ISO time string.

test_hour()[source]

Test that the hour property returns the correct value.

test_isoformat()[source]

Test that the isoformat method an ISO formatted string.

test_microsecond()[source]

Test that the microsecond returns the correct value.

test_minute()[source]

Test that the minute returns the correct value.

test_replace()[source]

Test that the replace

test_second()[source]

Test that the second returns the correct value.

test_strftime()[source]

Test that the strftime method returns a correctly formatting string.

test_tzinfo()[source]

Test that the tzinfo returns the correct value.

test_tzname()[source]

Test that the tzname method returns the timezone name.

test_utcoffset()[source]

Test that the utcoffset method returns the correct timezone offset.

class badidatetime.tests.test_datetime.TestBadiDatetime_timezone(name)[source]

Bases: TestCase

_classSetupFailed = False
_class_cleanups = []
test___eq__()[source]

Test that the __eq__ method returns True if equal and False if not equal.

test___getinitargs__()[source]

Test that the __getinitargs__ method returns the arguments that the timezone class was instantiated with.

test___hash__()[source]

Test that the __hash__ method returns a valid hash.

test___new__()[source]

Test that the __new__ method creates an instance from both a pickle object and a normal instantiation.

test___repr__()[source]

Test that the __repr__ method returns the correctly formatted string.

test___str__()[source]

Test that the __str__ method returns the correctly formatted string.

test__name_from_offset()[source]

Test that the _name_from_offset returns a string indicating the UTC offset.

test_badioffset()[source]

Test that the badioffset returns the correct timezone offset for the Badi coordinates.

test_dst()[source]

Test that the dst method always returns None.

test_fromutc()[source]

Test that the fromutc method correctly returns an updated dateime object.

test_tzname()[source]

Test that the tzname method returns the timezone name.

test_utcoffset()[source]

Test that the utcoffset method returns the correct timezone offset for the UTC coordinates.