Jump to content

repeating month and/or day of the month


oskrypuch

Recommended Posts

  • 3 months later...

Although this feature has been requested previously, I would also like to add my vote supporting the request for implementation of non-specific dates (e.g, every month, week, etc.) Thanks.

Link to comment

I would like to see a date function with variables as well. That would allow seasonal programs for holiday lighting in winter, and irrigating in summer without having to reset program condition values. Having a function that allows text could be useful too. But that's for another time perhaps.

Link to comment
  • 2 weeks later...

I would like to create a program based on working a 9/80 schedule and getting every other Monday or Friday off. That way, on the Monday/ Friday I'm off, the light sequence doesn't come on at 4:20 am while I'm sleeping in.

 

:lol:

Link to comment
I would like to create a program based on ... getting every other Monday or Friday off
You could set up a day counter using program variables. Look at this link where the sample counts down the days of a two week period. Pretty cool.

http://forum.universal-devices.com/viewtopic.php?t=6381

 

Sanders, thank you. I'll try to write a program to do this. This is probably better than a calendar app anyway.

 

I don't know enough to help anyone yet but I really appreciate the help. Most of these conversations are way over my head. Now if we talk Final Cut Pro, I can talk a little more intelligently.

Link to comment

I don't know how ISY keeps track of dates internally.

 

However, if you use MS Excel much, you know that they keep track of dates as an integer number where Jan 1, 1900 is day one. Every day since is just one number higher.

 

If ISY had this capacity, and you could compare it to a variable, that would make some complicated day tracking stuff more doable.

Link to comment

I have stated/requested several times that with variable support in place there could be several SYSTEM Variables such as CURRENT_MONTH, CURRENT_DAY, CURRENT_YEAR, CURRENT_WEEKDAY, etc. These would be read only, not changeable by programs.

Link to comment
I have stated/requested several times that with variable support in place there could be several SYSTEM Variables such as CURRENT_MONTH, CURRENT_DAY, CURRENT_YEAR, CURRENT_WEEKDAY, etc. These would be read only, not changeable by programs.

 

This would be very helpful.

 

A set of read only variables that are synced to the clock so power failures, reboots, or other errors can't mess the schedule up. Some of these things can be created using counters without changes to ISY, but I just fear the unforseen glitch messing up the counter at which point it would perpetually be wrong without manual intervention.

 

1-12 for months

1-7 for days (I know ISY already has days, but if you are going to do the variable thing, you might as well include it)

2 thousand and whatever for year

1-28,29,30,31 for day of month

Link to comment

Michel,

 

So you can use their date values, and make comparisons against other variables in program lines. Allows much more flexibility.

 

Example ...

 

If $system_month .LT. $max_range

and $system_month .GT. $min_range

 

then do_something

 

$max/'min_range can be changed as needed, elsewhere in the program.

 

Besides, day_of_month, month, year and day_of_week, having the system seconds, minutes and hour would be VERY powerful as well.

 

If you provide these system variables, be sure to establish a special naming convention that can't be used for user variables, eg. ...

 

$_sys_xxxxxxxx for a state system variable and ..

 

$sys_xxxxxxxx for an integer system variable.

 

* Orest

Link to comment
Hi guys,

 

We do have the month/day without year in our requirements. Why would we need variables for current day/current month in this case?

 

With kind regards,

Michel

 

If you wanted something to happen on the first day of every month, or 10th, or whatever.

 

If you wanted something to happen every year in feb, or mar, or whatever.

 

 

As it is now, you can only specify every Mon, or Tues, or whatever.

 

Plus, it would be nice to have it as a variable so you can do mathematical comparisons/modifications.

 

Or if you want something to happen every 3rd day, or every 4th day. This one you can do with counters, but you risk a power failure or reboot screwing up your counter and becomming a day off.

Link to comment

I wrote an entire series of programs to keep track of the day of week, day of month, month, year, day of the year. It accounts for leap year until the year 2100 (figured I would let someone else worry about that) Edit: fixed that, it is now good until 2400.

 

I would be happy to share them if anyone likes. I checked and double checked them for errors of logic. I think I am good, but with that many programs, who knows.

 

This requires you to go in and set the variables the first time you use it to the correct year, month, day of week, leap year status (2), day of month, day of year (May 22 is 142)

 

 

Folder Day of Month

Program Day of Month Advance
If
       Time is 12:00:00AM
   And (
            (
                 $iDay.of.Month < 31
             And (
                      $iMonth is 1
                   Or $iMonth is 3
                   Or $iMonth is 5
                   Or $iMonth is 7
                   Or $iMonth is 8
                   Or $iMonth is 10
                   Or $iMonth is 12
                 )
            )
         Or (
                 $iDay.of.Month < 30
             And (
                      $iMonth is 4
                   Or $iMonth is 6
                   Or $iMonth is 9
                   Or $iMonth is 11
                 )
            )
         Or (
                 $iDay.of.Month < 29
             And $iMonth is 2
             And $iLeap.Year is 0
            )
         Or (
                 $iDay.of.Month < 28
             And $iMonth is 2
             And $iLeap.Year > 0
            )
       )

Then
       $iDay.of.Month += 1
       $iDay.of.Month Init To $iDay.of.Month

Else
       $iDay.of.Month  = 1
       $iDay.of.Month Init To 1


 

Folder Day of Week

Program day of week
If
       Time is 12:00:00AM
   And $iDay.of.Week < 7

Then
       $iDay.of.Week += 1
       $iDay.of.Week Init To $iDay.of.Week

Else
       $iDay.of.Week  = 1
       $iDay.of.Week Init To 1



 

Folder Day of Year

program day of year advance
If
       Time is 12:00:00AM
   And (
            (
                 $iDay.of.Year < 365
             And $iLeap.Year > 0
            )
         Or (
                 $iDay.of.Year < 366
             And $iLeap.Year is 0
            )
       )

Then
       $iDay.of.Year += 1
       $iDay.of.Year Init To $iDay.of.Year

Else
       $iDay.of.Year  = 1
       $iDay.of.Year Init To 1


 

Folder Leap Year

program leap year remainder calculator
If
       Time is 12:00:02AM
   And $iDay.of.Year is 1
   And $iYear is not 2100

Then
       $iLeap.Year  = $iYear
       $iLeap.Year %= 4
       $iLeap.Year Init To $iLeap.Year

Else
  - No Actions - (To add one, press 'Action')


Folder Month

Program Month Advance
If
       Time is 12:00:01AM
   And $iDay.of.Month is 1
   And $iMonth < 12

Then
       $iMonth += 1
       $iMonth Init To $iMonth

Else
  - No Actions - (To add one, press 'Action')

Program Month Reset
If
       Time is 12:00:01AM
   And $iDay.of.Month is 1
   And $iMonth is 12

Then
       $iMonth  = 1
       $iMonth Init To 1

Else
  - No Actions - (To add one, press 'Action')



Folder State Variables

Program Transfer value to state variables
If
       Time is 12:00:02AM

Then
       $sDay.of.Month  = $iDay.of.Month
       $sDay.of.Week  = $iDay.of.Week
       $sDay.of.Year  = $iDay.of.Year
       $sLeap.Year  = $iLeap.Year
       $sMonth  = $iMonth
       $sYear  = $iYear
       $sYear Init To $sYear
       $sMonth Init To $sMonth
       $sLeap.Year Init To $sLeap.Year
       $sDay.of.Year Init To $sDay.of.Year
       $sDay.of.Week Init To $sDay.of.Week
       $sDay.of.Month Init To $sDay.of.Month

Else
  - No Actions - (To add one, press 'Action')

 

Folder Year

Program Year
If
       Time is 12:00:01AM
   And $iDay.of.Year is 1

Then
       $iYear += 1
       $iYear Init To $iYear

Else
  - No Actions - (To add one, press 'Action')


 

EDIT: OK, I hope you weren't watching this too close for the last couple hours as I made a bunch of changes. I found that seeing the programs all at once as this forum shows them when you cut and paste makes it a lot easier to find errors.

 

Anyway. Good news. As the programs sat at midnight my time, it worked. The day of week went to 1, the day of month went to 23, the day of the year went to 143. Then it all got erased becuase I had my transfer to state variables backwards, but no fear, I fixed it already. Of course testing the month changing and year changing, and leap year changing are all a bit off.

 

Edit: I discovered I can elliminate one program using the remainder function on the leap year. I changed it.

 

Edit: Just realized I can elliminate one more program by using the else clause in day of month advance for the new month.

Link to comment

    And $iYear is not 2100 

 

Wow, you must be a young dude! :wink:

 

Beautifully done. You realize that Michel could remove the need for all this with a few lines of code to provide system variable access, yes?

 

But a great exercise.

 

 

As a comment on your aside, I would also LOVE to be able to print out in full all the code, or certain parts of the code. it really makes debugging much easier then looking just one "line" at a time.

 

* Orest

Link to comment
    And $iYear is not 2100 

 

Wow, you must be a young dude! :wink:

 

Beautifully done. You realize that Michel could remove the need for all this with a few lines of code to provide system variable access, yes?

...

* Orest

 

Or, Michel could use your solution so that he does not have to implement those few lines of code (which are quite intrusive)! :wink:

 

With kind regards,

Michel

Link to comment

Very nice work, apostolakisl! Looks like I have a lot of fat fingering work ahead to enter your code. Many thanks for your effort on this - something I've been wanting to have for quite a while.

Link to comment

I have never done this, but export/import is available on ISY. I would be happy to send you them (especially the one with the rediculous number of parenthesis, I started getting dizzy trying to keep them all in order).

 

I hope it all works. The day of month works for sure from 22nd when I wrote it to today.

 

Maybe Michelle has a debugging ISY that can simulate multiple years of a program running? Perhaps he can run it all the way out to the year 2400 when my leap year calculation becomes wrong!

Link to comment
I wrote an entire series of programs to keep track of the day of week, day of month, month, year, day of the year. It accounts for leap year until the year 2100 (figured I would let someone else worry about that) Edit: fixed that, it is now good until 2400.

apostolakis,

 

This is excellent; well done! I've added a link to your post from our wiki, in the Programs section of the How-To Guide.

Link to comment

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...