Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to run on a specific day(s) of the week
#1
I have an action that I want to run on specific days - to make it easy, Monday to Friday only.

I was going to use IsInRange and use the day number, but that's the date and not the day number of the day in the week.

How to I run a triggered event on specific days only without creating a crap load of If statements.

The If IsInRange actually works well if the day number was 0-6.

Mick
Mykel Koblenz
Illawarra Smart Home
Reply
#2
One way to go about it would be to create a Time variable and set it to now. Then use the System::FormatTimeVal command to format it. Indicate you want to use the PATTERN type format, and set the format to %(A), which will format out the day of the week by name. If it's not Saturday or Sunday, then it's a weekday.

We could probably use a nicer way to do this sort of thing. I'll put it on the list.
Dean Roddey
Explorans limites defectum
Reply
#3
Thanks

Having the day as a number I think make the most sense as it is easier to manipulate. But it is at your discretion.
Mykel Koblenz
Illawarra Smart Home
Reply
#4
I think also an IsWeekDay or IsWeekend would be useful.
Flamin' Noobie...
Warp speed now and don't give me any of that dilythium crystal crap!
Reply
#5
Yeh, that's what I was going to do. IsWeekDay() handles one side, and negating it handles the other side.
Dean Roddey
Explorans limites defectum
Reply
#6
Yes, but if you don't want say Monday then what do you do.

If you have Sunday as 0 to Saturday as 6 then IsInRange allows you to do wed to fri, sat & sun and any other combination of sequential days.

Isweekday and IsWeekend are two subsets of the above.

Checking for a single day is easy as well then when its on a number to be used.

Just my 2 cents

Mick
Mykel Koblenz
Illawarra Smart Home
Reply
#7
The same command could also return the day of the week number.
Dean Roddey
Explorans limites defectum
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)