• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to create a Calendar event on a specific day of next month?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to create a Calendar event on a specific day of next month?


  • Subject: Re: How to create a Calendar event on a specific day of next month?
  • From: Jim Underwood via AppleScript-Users <email@hidden>
  • Date: Sat, 19 Jun 2021 23:13:32 +0000
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=apoemail.us; dmarc=pass action=none header.from=apoemail.us; dkim=pass header.d=apoemail.us; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VUgSHdzjt64w58GvJRiN+WYipZ4IgHCUlkfSetkwsiw=; b=J+A0BHQjOTf2KdpXvB2RNfaoMz2azOaCAGKhmrOYm3n1mxWndZXHdNIAfLu30Su9wqh7euJQMeJo37KNEGtOw1obZzBD94/iYbHuVklolAGLnoOIBHTIGmoGdA/z3AHpmsdkX/pXLlYx5uRACcP5nS9rO1vaZV5cOsIIpmRjJXyedPnn8DaHHHaHAruhGYRGUb2aOeV3Ak+ekaaIEIlMn/AFTwBm2xrlClbJ7GV/zBjkC56hSqTuwYGkTESxVQaS59d0yOdqzZFCemWcDhwQ1ySxsegNfZNdj4RNaYu9VOpMdtguwE7UBu3BAq9NMNwljE4NskblPzVUgbVizY9IQw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WBNsaO/HHzIJI4/mnYG9EsGIKH/qmREw/ZbDjY5DBRS16d5USBAroDJuYlQLqmARXnAAAdKIEysNS5/3PjTdmozjDDm20VaU/sXKy2pOr6rVZj+3C44x+4yIX2EmBxQtKJa+Z+2+/0h/fayqVhhC8ENvmNjB7ybXPJkWa/ExMQWyvJYLO18QZOJNPWDDrYI4Rs3ydxgUL0YQq3sZ++qjCyfW2DuxMKfowTdpN193wfSwPqc6tM4JKwJX5+LNFpM5gPJxgtFzBs1/cqgGtxxpf5uYzk3djUg7AubUrY05KUyJSXV64ui05FMPvW1kqMlk9E8M8wghsIeKsymx3kzX5Q==
  • Thread-topic: How to create a Calendar event on a specific day of next month?

Hi Jim,

Manipulating dates in AppleScript is one of the most frustrating tasks there
is, especially if you are familiar with other languages that have rich date
functions built in.

IAC, I hope you'll find this helpful.

First, here's a great date resource:

Dates & Times in AppleScripts -- MacScripter Adam Bell et
al<https://macscripter.net/viewtopic.php?id=24737>

I actually reviewed that again, but did not find a concise solution to your
problem, but I may have missed it since there is so much there.  I'm sure that
Nigel Garvey will jump in if it missed it, or there is a better method.


So, here is what I came up with, based in part on the MacScripter's scripts
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
property ptyScriptName : "Get Next Month Same Day"
property ptyScriptVer : "1.0"
property ptyScriptDate : "2021-06-19"
property ptyScriptAuthor : "JMichaelTX"

(*
    REF: Dates & Times in AppleScripts -- MacScripter/Adam Bell et al
            https://macscripter.net/viewtopic.php?id=24737)
            2007-07-23
*)

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

copy startDate to nextMonth

--- Set to Next Month After StartDate ---
set nextMonth's day to 32

--- Set to the Month After Next Month --
set nextMonth's day to 32
set manmDay to day of nextMonth

--- Now Set Back to Last Day of Next Month ---
set nextMonth to nextMonth - (manmDay * days)
set lastDay to day of nextMonth

--- Finally Set the Day of Next Month, but no later than it's last day ---
if (d ≤ lastDay) then
  set nextMonth's day to d
end if

return nextMonth


-->date "Monday, July 19, 2021 at 6:04:51 PM"
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Best Regards,

Jim Underwood
aka JMichaelTX



From: "ASUL (AppleScript)" <email@hidden>
Reply-To: Jim Krenz <email@hidden>
Date: Saturday, June 19, 2021 at 3:24 PM
To: "ASUL (AppleScript)" <email@hidden>
Subject: How to create a Calendar event on a specific day of next month?

Hello all,

I am trying to create a Calendar event on a specific day of next month (the
18th, in this case).

I am using this workaround, as I generally create the event a month in advance:

set theStartDate to (current date) + (30 * days)

But due to months having different quantities of days (or the day that I
execute the script), the event may be created on the wrong day.

Here is the draft of the entire script:

set theStartDate to (current date) + (30 * days)
set hours of theStartDate to 14
set minutes of theStartDate to 0
set seconds of theStartDate to 0
set theEndDate to theStartDate + (3 * hours)
tell application "Calendar"
tell calendar "Home"
set newEvent to make new event at end with properties {summary:”Rent is due",
location:"Venmo", allday event:true, start date:theStartDate, end
date:theEndDate, description:"This is your courtesy reminder to pay your
rent.", url:"https://venmo.com/account/sign-in"}
tell newEvent
make new sound alarm at end of sound alarms with properties {trigger
interval:840, sound name:"Crystal"}
make new sound alarm at end of sound alarms with properties {trigger
interval:-120, sound name:"Crystal"}
make new sound alarm at end of sound alarms with properties {trigger
interval:-10200, sound name:"Crystal"}
end tell
end tell
end tell

Thanks for any help!

Sincerely,

Jim

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: How to create a Calendar event on a specific day of next month?
      • From: Jim Krenz via AppleScript-Users <email@hidden>
References: 
 >How to create a Calendar event on a specific day of next month? (From: Jim Krenz via AppleScript-Users <email@hidden>)

  • Prev by Date: How to create a Calendar event on a specific day of next month?
  • Next by Date: Re: How to create a Calendar event on a specific day of next month?
  • Previous by thread: How to create a Calendar event on a specific day of next month?
  • Next by thread: Re: How to create a Calendar event on a specific day of next month?
  • Index(es):
    • Date
    • Thread