Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Surya Narayana
/
ai-workforce-rasa
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8d65b219
authored
Jan 15, 2021
by
Rajeev Uppala
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
past date condition and year wise conditon changed
parent
1b6fb137
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
10 deletions
actions/actions.py
actions/actions.py
View file @
8d65b219
...
...
@@ -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
=
[
"2
021-01-01"
,
"2021-05-31"
,
"2021-07-05"
,
"2021-09-06"
,
"2021-11-25"
,
"2021-11-26"
,
"2021-12-24"
,
"20
21-12-27"
]
HolidaysList
=
[
"2
1-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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment