diff --git a/brutils/__init__.py b/brutils/__init__.py index aad91924..18353340 100644 --- a/brutils/__init__.py +++ b/brutils/__init__.py @@ -41,10 +41,10 @@ from brutils.cpf import ( remove_symbols as remove_symbols_cpf, ) -from brutils.date import ( +from brutils.date_utils import ( is_holiday, ) -from brutils.date import ( +from brutils.date_utils import ( is_holiday as is_holiday_date, ) diff --git a/brutils/date.py b/brutils/date_utils.py similarity index 78% rename from brutils/date.py rename to brutils/date_utils.py index d66e9273..aef9b9db 100644 --- a/brutils/date.py +++ b/brutils/date_utils.py @@ -4,7 +4,7 @@ import holidays -def is_holiday(date: datetime, uf: str = None) -> Union[bool, None]: +def is_holiday(target_date: datetime, uf: str = None) -> Union[bool, None]: """ Checks if the given date is a national or state holiday in Brazil. @@ -15,7 +15,7 @@ def is_holiday(date: datetime, uf: str = None) -> Union[bool, None]: The method does not handle municipal holidays. Args: - date (datetime): The date to be checked. + target_date (datetime): The date to be checked. uf (str, optional): The state abbreviation (UF) to check for state holidays. If not provided, only national holidays will be considered. @@ -42,20 +42,20 @@ def is_holiday(date: datetime, uf: str = None) -> Union[bool, None]: True """ - if not isinstance(date, datetime): + if not isinstance(target_date, datetime): return None valid_ufs = holidays.Brazil().subdivisions if uf is not None and uf not in valid_ufs: return None - national_holidays = holidays.Brazil(years=date.year) + national_holidays = holidays.Brazil(years=target_date.year) - if date in national_holidays: + if target_date in national_holidays: return True if uf is not None: - state_holidays = holidays.Brazil(prov=uf, years=date.year) - return date in state_holidays + state_holidays = holidays.Brazil(prov=uf, years=target_date.year) + return target_date in state_holidays return False diff --git a/tests/test_date.py b/tests/test_date_utils.py similarity index 98% rename from tests/test_date.py rename to tests/test_date_utils.py index 2b81fc61..b7350da2 100644 --- a/tests/test_date.py +++ b/tests/test_date_utils.py @@ -1,7 +1,7 @@ from datetime import datetime from unittest import TestCase -from brutils.date import is_holiday +from brutils.date_utils import is_holiday class TestIsHoliday(TestCase):