This is a nice snippet I got from an ESRI dev that returns what day a location has open in the Pro Symbology Expression Builder. It uses the DaysOpen field in my layer. My field values are like so: Su,M,Tu,W,Th,F,Sa.
Here is the expression:
var days_abbr = ["Su", "M", "Tu", "W", "Th", "F", "Sa"];
var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
var weekday = Weekday(Today());
If(Find(days_abbr[weekday],$feature.DaysOpen,0)!=-1) {
return "Open (" + days[weekday] + ")";
}
else {
return "Closed";
}
My question here is how to expand on that to include time using the Find() function. I created similar variables to get the time.
Here is one attempt which returns an error (see pseudo text below) on the If() line.
var days_abbr = ["Su", "M", "Tu", "W", "Th", "F", "Sa"];
var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
var weekday = Weekday(Today());
var hours = ["8","8.5","9","9.5"]; //I also tried ["8","8:30","9","9:30"] which resulted in error
var timeofday = Time(Now()); //this displays the time the way I anticipated it
If(Find(days_abbr[weekday],$feature.DaysOpen,0)!=-1 && Find(hours[timeofday],$feature.Time,0)!=-1) {
return "Open Now";
}
else {
return "Closed";
}
// Error: Invalid expression. Integer index expected.