date_utils.py

About this file

This file contains the utils functions pertaining to dates.
The functions creates the date submission for a request, returns the next business date, returns the due date, converts data to utc, returns timezone difference, and returns a list of holidays.

Few functions explanation:
'get_following_date(date_created)'
This generates the date submitted for a request. It returns the date_created rounded off to the next business day.

'get_next_business_day()'
This generates the next business day based on the current date. And it returns the datetime object with the next business day set to 13:00 PM UTC (09:00 AM EST).

'get_due_date(date_submitted, days_until_due, tz_name)'
This generates the due date for a request. It returns the due date (utc) with time set to 22:00 PM (5:00 PM EST).

'process_due_date(due_date)'
This returns the given datetime object with a utc time equivalent to 5:00 PM local time (app).

'get_holidays_date_list(year_start, year_end=None)'
This generates a list of holiday dates in the range of specified years (including year_end). It returns a list of dates formatted as strings ['MM/DD/YYYY']

Code Check Report


No problems to report
                        

Documentation drawn from source code


get_following_date(date_created):

Generates the date submitted for a request.

:param date_created: date (local) the request was made
:return: date submitted (local) which is the date_created rounded off to the next business day

get_next_business_day():

Generates the next business day based on the current date
:return: datetime object with the next business day set to 13:00 PM UTC (09:00 AM EST)

get_due_date(date_submitted, days_until_due, tz_name):

Generates the due date for a request.

:param date_submitted: date submitted (local) which is the date_created rounded off to the next business day
:param days_until_due: number of business days until a request is due
:param tz_name: time zone name (e.g. "America/New_York")

:return: due date (utc) with time set to 22:00 PM (5:00 PM EST)

process_due_date(due_date):

Returns the given datetime object with a utc time equivalent to 5:00 PM local time (app).

:param due_date: unprocessed request due date (local)
:return: naive datetime object

local_to_utc(date, tz_name):

utc_to_local(date, tz_name):

get_timezone_offset(date, tz_name):

get_holidays_date_list(year_start, year_end=None):

Generate a list of holiday dates in the range of specified years (including year_end)

:param year_start: 4 digit year e.g. 2016
:param year_end: 4 digit year e.g. 2022

:return: List of dates formatted as strings ['MM/DD/YYYY']

get_release_date(initial_date, days_until_release, tz_name):

is_business_day(date):

Determine if the provided date is a business day.
Args:
date: local date.

Returns:
bool: True if date is a business day.

Source code