Hey Guys,
I have a variable in my pool, data type text, called ‘isWeekend’. As default, the variable is set to ‘No’.
I’d like a script on a service to:
Get todays date.
Compare the date to see if it is a ‘Saturday’ or ‘Sunday’.
Return ‘Yes’ if it is saturday or sunday, otherwise, ‘No’.
Any pointers would be really great…
For bonus points, it would be great if the script yould return ‘Yes’ for any time outside of 9am - 5pm Monday - Friday. For Monday - Friday, it should say ‘No’.
But, any pointers for the question at the top would be a great help…
Hopefully you don’t have to concern yourself with different jurisdictions…some people have weekends = Friday/Saturday. In your process what about Shift workers/part-time workers/flexitime workers etc…
Also consider Daylight savings…does that change as well?
Anyway - here is my code and I’m claiming the extra points for including the hours…
def mydate = new Date(System.currentTimeMillis())
int theExactDay
int theExactHour
def endResult = "No"
theExactDay = mydate.getDay();
theExactHour = mydate.getHours();
if(theExactDay == 0||theExactDay == 6){
endResult = “Yes”}
else{
if(9<theExactHour && theExactHour<17){
//if between these numbers then Not IsWeekend
endResult = “No”
}
}
if(endResult.equalsIgnoreCase(“Yes”)){
return “Yes”}
else{
return “No”}
Bonitasoft empowers development teams with Bonita, the open-source and extensible platform to solve the most demanding process automation use cases. The Bonita platform accelerates delivery of complex applications with clear separation between capabilities for visual programming and for coding. Bonita integrates with existing solutions, orchestrates heterogeneous systems, and provides deep visibility into processes across the organization.