in functions/orchestration-helpers/pipeline-executor/main.py [0:0]
def process_dates(validation_date_pattern, same_day_execution):
"""method to process start and end dates when no received by parameter
Args:
validation_date_pattern: python data pattern format to apply to start and end dates
same_day_execution: can be YESTERDAY, TODAY or YESTERDAY_TODAY indicating dates that should be passed in
start and end dates, if not received by parameter.
Returns:
Start and end dates parsed
"""
today = date.today()
# if is a daily pattern, execute the previous day
if validation_date_pattern == DEFAULT_TIME_FORMAT:
if same_day_execution == 'YESTERDAY':
last_day = today - timedelta(days=1)
else: # TODAY, YESTERDAY_TODAY
last_day = today
end_date = str(last_day.strftime(validation_date_pattern))
if same_day_execution == 'TODAY':
start_date = today
else: # YESTERDAY_TODAY, YESTERDAY
start_date = today - timedelta(days=1)
start_date = str(start_date.strftime(validation_date_pattern))
# is a monthly pattern, execute the pattern the last month with regard
# to the actual date
else:
first = today.replace(day=1)
last_month_last_day = first - timedelta(days=1)
last_month_first_day = last_month_last_day.replace(day=1)
end_date = str(last_month_last_day.strftime(validation_date_pattern))
start_date = str(last_month_first_day.strftime(validation_date_pattern))
return start_date, end_date