Hi,
I am pretty new at arcade so I have been struggling with this problem for a bit here.
I am trying to write arcade for a conditional visualization where every Monday at 12:01 AM all of the trash bin points will reset to turn orange. They should remain orange until the bin is serviced. After the bin is serviced it turns green and starts a counter for 48 hours. If the bin is not serviced in 48 hours, it turns orange again.
I have code that works for the second part but not the defaulting to orange every Monday morning. I am trying to use ISOWeekday to call the day of the week ("1") and the Hour ("0"), but I cant figure out how to write this so it works.
Thanks in advance.
Var Enhanced1 = Date($feature["Date"])
if(DateDiff(Now(), Enhanced1, 'hours')<48){
Var Status = "Does not need Servicing";
}
if(DateDiff(Today(), Enhanced1, 'hours')>=48){
Var Status = "Needs Servicing";
}
Return Status
This seems to work for me. I simplified your expression a little, making the default condition of "Needs Servicing". If the service date is within 48 hours, then it changes to "Does not need Servicing", but it reverts to "Need Servicing" if the pickup date was Saturday or Sunday and today's date is Monday or Tuesday. The variable FakeToday simulates different days of the week.
var PickupDate = $feature.DATE;
var FakeToday = Date(2022,7,29,0,02)
var Status = "Needs Servicing";
if (DateDiff(FakeToday, PickupDate, 'hours') < 48){
Status = "Does not need Servicing";
if (ISOWeekday(PickupDate) > 5 && ISOWeekday(FakeToday) < 3) {
Status = "Needs Servicing";
}
}
Thank you! This helped!