I have a Calendar called “My Company” where I need to create an evert the business day before the last business day.
Example: February 2021 ends on a sunday. The last business day of february is 26, friday. I need to set an event febuary 25.
Another example: May 2021 ends on a monday. The business day before that is friday 28. But suppose that was a holiday. Then the business day before the last business day of may would be thursday 27.
The calendar I am trying to check against is this one
http://icalshare.com/calendars/3372
that I call inside Calendar “Feriados Portugal”.
This is my script so far.
set numberOfDaysPerMonth to {}
set templateDates to {}
set i to 1
repeat while i < 13
	copy (current date) to newDate
	set currentYear to year of newDate
	set the month of newDate to (i as integer)
	set the day of newDate to (1 as integer)
	
	set numberOfDaysOnMonth to GetNumberOfDaysInMonth(newDate)
	copy numberOfDaysOnMonth to end of numberOfDaysPerMonth
	
	--	copy {i:newDate} to end of templateDates
	
	set i to i + 1
end repeat
my GetNumberOfDaysInMonth(newDate)
# Returns the number of days in the month that the given date falls in.
# Example:
#     my GetNumberOfDaysInMonth(current date)
on GetNumberOfDaysInMonth(aDate)
	local aDateCopy
	copy aDate to aDateCopy
	set day of aDateCopy to 1
	if month of aDateCopy is December then
		set year of aDateCopy to ((year of aDateCopy) + 1)
		set month of aDateCopy to 1
	else
		set month of aDateCopy to ((month of aDateCopy) + 1)
	end if
	return day of (aDateCopy - 1 * days)
end GetNumberOfDaysInMonth
this script discovers the last day of each month and stores it at numberOfDaysPerMonth
Now I am trying to get all events from calendar “Feriados Portugal” using this code:
tell application "Calendar"
	tell calendar "Feriados Portugal"
		set eventos to every event
		display dialog start date of first event of eventos
	end tell
end tell
this is what I get just for the first event!:https://ibb.co/SxwjF0s
What I need is simply a list of dates.