No. I’m saying that if I double-click the events in Calendar while time zone support is off, the inspector windows simply show the start and end times transposed to my time zone .
. whereas if I do the same with time zone support on, the inspector windows show the times as for the original zone, with a “time zone” property underneath:
In both cases, the events are shown transposed to my local time in the calendar display.
However, the “time zone” entry in an inspector window is a pop-up menu which allows other zones to be selected. Selecting another zone here causes the times to be reinterpreted as if they were from that zone. So if I change the time zone of your Hawaiian event to UTC, 07:10 Hawaii-Aleutian Standard Time becomes 07:10 UTC and the event shifts in the calendar display from 18:10 to 08:10 United Kingdom Time. Clicking “Apply” in the inspector window makes the change permanent and edits the start and end time entries in the event’s calendar file.
If I return the event to Hawaii-Aleutian Standard Time and export the calendar from Calendar, the exported file’s X-WR-TIMEZONE has my time zone. There’s also a VTIMEZONE object with details of how to interpret yours.
I tried changing the time zone in the VEVENT last night and didn’t notice the time zone in the inspector window. I’ll check out your observations. Thanks for the in-depth explanation. Now I think I understand.
I think I’ve found what is wrong with my script that writes to file. There are carriage returns! Just thought of something. Maybe I copied an pasted the returns into some text. So what I need to do is check the script’s text.
One of the nice things with BBEdit and TextWrangler, is that it is so easy to see invisbles. Especially when it comes to hard spaces in a shell script, but it should work for you as well, when you look for carriage returns. No need for hexedit, od -cb, or xxd.
I tried Text Wrangler but didn’t get anything. But with this script, I found something strange:
set t to quoted form of "summary1
time1
summary2
time2"
set cmd to "sed -e '
1 {
i\\
BEGIN:VCALENDAR\\
VERSION:2.0\\
X-WR-CALNAME;VALUE=TEXT:OurMeetings\\
X-WR-TIMEZONE:Pacific/Honolulu\\
PRODID:-//Kel.Meetings//MeetingsCal 1.0//EN\\
CALSCALE:GREGORIAN
}
i\\
BEGIN:VEVENT
s/.*/SUMMARY: &/
n
s/.*/DTSTART;TZID=Pacific\\/Honolulu:&/
a\\
END:VEVENT
$ a\\
END:VCALENDAR
'"
set r to do shell script "echo " & t & " | " & cmd -- & " >~/Desktop/TestCal.ics" -- write to file
offset of return in r
→ 16
So, I have a carriage return at the end of the first line. I can’t figure out why so far. I think this is the script where I searched the script for Returns and didn’t find any. I don’t think Sed would return Returns.
Edited: I think I’ve found what’s wrong in the script. The text I used had "return & linefeed’. Probably got that from downloading the basic calendar file text.
I was making some stupid mistakes. Finally, got the script working up to making the file.
-- make some dates
set cd to current date
set d1 to cd + 1 * hours
set d2 to cd + 2 * hours
set summary1 to "Meeting at " & (time string of d1)
set summary2 to "Meeting at " & (time string of d2)
set date1 to MakeCalDate(d1)
set date2 to MakeCalDate(d2)
set t to quoted form of (summary1 & linefeed & date1 & linefeed & summary2 & linefeed & date2)
set cmd to "sed -e '
1 {
i\\
BEGIN:VCALENDAR\\
VERSION:2.0\\
X-WR-CALNAME;VALUE=TEXT:OurMeetings\\
X-WR-TIMEZONE:Pacific/Honolulu\\
PRODID:-//Kel.Meetings//MeetingsCal 1.0//EN\\
CALSCALE:GREGORIAN
}
i\\
BEGIN:VEVENT
s/.*/SUMMARY: &/
n
s/.*/DTSTART;TZID=Pacific\\/Honolulu:&/
a\\
END:VEVENT
$ a\\
END:VCALENDAR
'"
set r to do shell script ("echo " & t & " | " & cmd) without altering line endings
set f to choose file name
set ref_num to open for access f with write permission
write r to ref_num
close access ref_num
on MakeCalDate(d)
set time1 to d as «class isot» as string
set AppleScript's text item delimiters to {"-", ":"}
set temp_list to text items of time1
set AppleScript's text item delimiters to {""}
set time1 to temp_list as string
return time1
end MakeCalDate
Retyping it really helped in finding the mistakes.
Here’s the final script for now. Now I can test and modify.
-- Makes new calendar with events or adds to existing calendar.
-- get Calendar folder
set docs_path to (path to documents folder) as string
set cal_folder to docs_path & "Calendars:"
tell application "System Events"
if not (exists folder cal_folder) then
make new folder at folder docs_path with properties {name:"Calendars"}
end if
end tell
set file_spec to cal_folder & "Meetings1.ics"
set file_spec_pp to POSIX path of file_spec
-- get user timezone name
set userTZ to (do shell script ("readlink '/etc/localtime' | sed 's|/usr/share/zoneinfo/||'"))
-- make some dates
set cd to current date
set d1 to cd + 1 * hours
set d2 to cd + 2 * hours
set summary1 to "Meeting at " & (time string of d1)
set summary2 to "Meeting at " & (time string of d2)
set dt1 to d1 as «class isot» as string
set dt2 to d2 as «class isot» as string
set t to quoted form of (summary1 & linefeed & dt1 & linefeed & summary2 & linefeed & dt2)
-- Sed make calender file text and save to file command
set cmd to "sed -e '
1 {
i\\
BEGIN:VCALENDAR\\
VERSION:2.0\\
X-WR-CALNAME;VALUE=TEXT:OurMeetings\\
X-WR-TIMEZONE:" & userTZ & "\\
PRODID:-//Kel.Meetings//MeetingsCal 1.0//EN\\
CALSCALE:GREGORIAN
}
i\\
BEGIN:VEVENT
s/.*/SUMMARY: &/
n
s/[-:]*//g
s_.*_DTSTART;TZID=" & userTZ & ":&_
a\\
END:VEVENT
$ {
a\\
END:VCALENDAR
}
'"
-- run sed command with input text (events' summaries and dates)
set r to do shell script ("echo " & t & " | " & cmd & " >" & file_spec_pp)
set file_ref to (file_spec) as alias
say "[[slnc 1000]] Select \"New Calendar\" from the popup menu to create a new calendar. [[slnc 500]] Or, [[slnc 400]] select an existing calendar to add events." without waiting until completion
-- open the file in Calendar
tell application "Calendar"
launch
activate
open {file_ref}
end tell
I still need to check on the timezone changes. Got sidetracked.
Edited: changed the script a little.
Edited: the script.
Edited: had to edit the script one last time. Exchanged Finder for System Events.
This thread was fascinating. Since the Apple Calendar app and Microsoft Outlook seem to be unable to add excluded dates, my next project is to write a script to batch process a folder with a bunch of ICS files in it and add excluded dates to each event.
The excluded dates field in ICS files look something like: