Commit 8d65b219 by Rajeev Uppala

past date condition and year wise conditon changed

parent 1b6fb137
Showing with 18 additions and 10 deletions
......@@ -30,23 +30,31 @@ def ExtractMobilenumber(slot_to_fill):
return mobile_numbers_list
def validate_available_date(date_text):
try:
timestamp = int(datetime.strptime(date_text, '%m/%d/%Y %I:%M %p').strftime("%s"))
timestamp = int(datetime.strptime(date_text, '%m/%d/%y %I:%M %p').strftime("%s"))
new_date_text = datetime.fromtimestamp(timestamp)
print("new_date_text",new_date_text)
HolidaysList = ["2021-01-01","2021-05-31","2021-07-05","2021-09-06","2021-11-25","2021-11-26","2021-12-24","2021-12-27"]
HolidaysList = ["21-01-01","21-05-31","21-07-05","21-09-06","21-11-25","21-11-26","21-12-24","21-12-27"]
dayNumber = int(new_date_text.strftime('%w')) #To check weekend or weekday
print("daynumber",dayNumber)
dateCheck = new_date_text.strftime('%Y-%m-%d') #To check for public holidays
dateCheck = new_date_text.strftime('%y-%m-%d') #To check for public holidays
print("dateCheck",dateCheck)
timeCheck = new_date_text.strftime('%-H') #To check for office hours
print("timeCheck",timeCheck)
if dayNumber not in [0,6]:
print("passed 1")
if dateCheck not in HolidaysList:
print("passed 2")
if int(timeCheck) >=9 and int(timeCheck) <= 17:
print("passed 3")
return True
date_format = "%m/%d/%y %I:%M %p"
# create datetime objects from the strings
givenDate = datetime.strptime(date_text, date_format)
presentDate = str(datetime.now().strftime("%m/%d/%y %I:%M %p"))
presentDate = datetime.strptime(presentDate, date_format)
if givenDate >= presentDate:
print("passed past date check condition")
if dayNumber not in [0,6]:
print("passed weekday condition")
if dateCheck not in HolidaysList:
print("passed non holidays day condition")
if int(timeCheck) >=9 and int(timeCheck) <= 17:
print("passed working hours condition")
return True
return False
except Exception as e:
print("FALSE in validate_available_date",e)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment