Date Transform¶
Functions responsible for handling date operations, such as adding or subtracting days.
- add_days_on_date(date: datetime, days: int) datetime[source]
Add days on a date
- Parameters:
date (datetime) – Date string in format YY-MM-DD.
days (int) – Days to add
- Returns:
Return a datetime in format YY-MM-DD.
- Return type:
datetime
- calculate_days(start_str_date, end_str_date)[source]
- final_day_of_month(month: int, year: int) int[source]
Determine how many days a given month has.
- Parameters:
month (int) – The month (1-12).
year (int) – The year.
- Returns:
Number of the days in the given month
- Return type:
int
- get_date_loop(start_date_object: dict, end_date_object: dict, year_reference: int) tuple[int, int][source]
Return the interval of months in an loop.
- Parameters:
start_date_object (dict) –
- Dictionary containing:
’year’ (int): Year of the start date
’month’ (int): Month of the start date
end_date_object (dict) –
- Dictionary containing:
’year’ (int): Year of the end date
’month’ (int): Month of the end date
year_reference (int)
- Returns:
(start_month_loop, end_month_loop)
- Return type:
tuple ([int, int])
- is_a_leap_year(year: int) bool[source]
Determine whether a given year is a leap year.
- Parameters:
year (int) – The year to be evaluated.
- Returns:
‘True’ if the year is a leap year, ‘False’ otherwise
- Return type:
bool
- subtract_days_on_date(date: datetime, days: int) datetime[source]
Subtract days on a date
- Parameters:
date (datetime) – Date string in format YY-MM-DD.
days (int) – Days to subtract
- Returns:
Return a datetime in format YY-MM-DD.
- Return type:
datetime
- transform_date_into_string(date: datetime) str[source]
Convert a date into a string
- Parameters:
date (str) – Date in format YY-MM-DD.
- Returns:
Return a date string in format YY-MM-DD.
- Return type:
date
- transform_string_into_date(date_str: str) datetime[source]
Convert a string into a date
- Parameters:
date_str (str) – Date string in format YY-MM-DD.
- Returns:
Return a date in format YY-MM-DD.
- Return type:
date
- transform_string_on_number_list(date_str: str) dict[str, int][source]
Splits a date string in the format ‘YYYY-MM-DD’ into ‘year’, ‘month’, ‘day’.
- Parameters:
date_str (str) – Date string formatted as ‘YYYY-MM-DD’.
- Returns:
Retorna um dicionário com as chaves ‘year’, ‘month’, ‘day’.
- Return type:
dict (dict[str, int])