Manipulating tomorrow's date, or another future date

Hello, all, long time to type.

I cannot believe how hard this is to solve, but I am stamped. I need to get dates simular to this

set {year:y, month:m, day:d} to (current date)

but instead of current date, I need tomorrow’s date. or a date two days from now. No mixture of adding +1 or +2 to (current date) will result in a change of the date that gets output. If I manually add 1 or 2 to my days, months or years I need to check to make sure May hasn’t slipped into June, and 2019 into 2020, and so on.

There has to be an elegant way to get the year, month and day of one or two days in the future, that isn’t prone to breaking left and right. Hope someone can help!

``````set n to 3 -- or whatever
set {year:y, month:m, day:d} to ((current date) + n * days)

``````

Or

``````set oneDay to 24 * 60 * 60
set {year:y, month:m, day:d} to (current date) + 2 * oneDay
{y, m, d}
``````

AppleScript mathematical manipulations are with seconds

``````set {year:y, month:m, day:d} to (current date) + 2
``````

is 2 seconds later

I’m always puzzled when I see someone creating a variable when this one is already defined by the system.

AppleScriptLanguage Guide carefully define four constants :

minutes
60
hours
60 * minutes
days
24 * hours
weeks
7 * days

So I don’t understand the need for an instruction like :
set oneDay to 24 * 60 * 60
which is exactly what days is supposed to be.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 23 juillet 2019 14:11:51

I specifically wrote “custom day” in this form, so that a person would understand why his script with “+ 2” showed “today’s frozen date.” The problem with experienced programmers is one - they can not clearly explain to the beginner what they are wrong. In any case, it is better to teach a novice programmer to think for himself so that he can do the math with dates in AppleScript himself.

Agreed.

@CK

Thank you.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 24 juillet 2019 15:36:30

I couldn’t find this at first but then located it under date operators in “Class Reference”:

https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_classes.html#//apple_ref/doc/uid/TP40000983-CH1g-246384

There are a number of very helpful examples.

Thanks for everyone’s help!