I am trying to write an applescript, but failing miserably.
What I want to do is the following:
I want to be able to go to a screen on my iPad and set a date for when I will be back from vacation. 2 days prior that date I want my "HouseMode" to swap from "Vacation" to "Away", thereby starting to heat up the house again.
What I am struggling with is calculating dates using Applescript, and getting the results to change a scheduled time/date trigger.
I have made the following variables:
VacationDay = the day of the month I will be back from vacation, example: 01
VacationMonth = the month (as an integer) I will be back from vacation, example: 04
VacationYear = the year I will be back from vacation, example: 2015
VacationRetur = a combination of the three variables above, giving example: 01042015
VacationDuration= Number of days from todays date until VacationRetur - 2 days. Example: 6
What I want to do Is make a script comparing todays date to VacationReturn, then populate VacationReturn.
VacationReturn would then be used to set the date of a trigger that changes my HouseMode from "Vacation" to "Away".
So for the example of me being on vacation until 1. April 2015, the script should set the trigger date on the 30. March 2015.
I have tried to use several guides, but I am struggling to get the date formats into a format that will not produce an error, and will calculate.
Anybody that can help me get started on this one? I think if I was shown how to properly calculate the difference between VacationReturn and todays date, I could manage the rest myself.