We are migrating the facility rounds (clip board and paper) to tablets with an Ignition HMI. Being that I am new to Ignition expression scripting, this post is a solicitation for feedback. Below are the methods I used to find what shift it currently is using the workweek even/odd cycle and the start time of current shift. These are expression tags referenced in other expressions, mainly the numeric input template to set background color to indicate its been looked at.
Shift Expression
if(
toBoolean(dateExtract(now(0), 'week') % 2 > 0),
//AD Long, evaluate time
if(timeBetween(now(), "7:00:00 am", "7:00:00 pm"),
if(toint(getDayofweek(now()))<5,"A","C"),
if(toint(getDayofweek(now()))>3,"D","B")),
if(timeBetween(now(), "7:00:00 am", "7:00:00 pm"),
if(toint(getDayofweek(now()))<4,"A","C"),
if(toint(getDayofweek(now()))=4|5|6,"D","B"))
)
Start of current shift expression
//start with seeing if its after 7pm,
//true=set start time to current day at 19:00
//false = if statement to see if less than 7am.
//true = set start time to 19:00 of the prior day
//false = set start time to 7:00 of current day.
if(gethour24(now())>19,
settime(getDate(getYear(now(0)),getMonth(now(0)),toint(getDayOfMonth(now(0)))),19,0,0),
if(gethour24(now())<7,
settime(getDate(getYear(now(0)),getMonth(now(0)),toint(getDayOfMonth(now(0))-1)),19,0,0),
settime(getDate(getYear(now(0)),getMonth(now(0)),toint(getDayOfMonth(now(0)))),7,0,0)
)
)