Creating iCalendar file

Hi,

I’m creating an .ics file and couldn’t find info on some things. Here’s a basic file:

Firstly, is the X-WR-TIMEZONE mandatory? I don’t see how it affects the calendar date and time.

Edited: also, do you know what it’s used for?

Edited: to be more specific, I have a calendar that uses this information, but it is wrong. Instead of my time zone, it uses the mainland time zone (US/Pacific) and the times do not change. In the first place, I don’t how they got (US/Pacific) and in the second place it doesn’t seem to really matter with the Calendar dates and times.

Thanks,
kel

Hello.

Have a look at this link.

Good Luck! :slight_smile:

Hi McUsr,

Interesting link. From the link:

I need to think twice about what this says.:slight_smile:

Later,
kel

Hello.

Maybe you could create a file, import it into Calendar, and then add some Calendar events with Applescript, and look at the changes?

Just a thought.

I don’t think X-WR-TIMEZONE is needed. What the link is saying is that you can use the VTimeZone in a block to change the time. Haven’t tried that yet, just thinking about the file. I haven’t found any straight forward and in depth info on ics files but getting there.:slight_smile:

Hi McUsr,

I found a good reference here:
http://www.rfc-editor.org/rfc/rfc2445.txt
It seems to explain everything.

Thanks a lot,
kel

Hello kel.

That is great, thanks. I was begrugding that I had to read rfc5545. :slight_smile:

Thanks.

P.S.

If you try the Accurate Moonphases script I have posted in Code Exchange you’ll discover that you can create ICal events automatically by pressing your mouse on the date of one such event, if you have data-detectors enabled in TextEdit.

I figured out how to use the timezone:

The DTSTART date for the second event ends with Z which means it is utc time (no offset). This event will use the X-WR-TIMEZONE:Pacific/Honolulu and adjust the time in Calendar ( for me -10 hours). The first event DTSTART:20131010T071000 has no Z and is absolute with no adjustment in Calendar.

That clears it up for me.

Thanks a lot,
kel

Hello.

It is truly great that you figured it out so quickly! :slight_smile:

Thanks!

Actually, I had a little help. :slight_smile:

No, that’s wrong. The utc times (Z) are automatically change to local time and the X-WR-TIMEZONE is not really used according to my tests.

Hello.

I find that comforting, as I couldn’t find any reference to the X-WR-TIMEZONE format when I glanced through the rfc. Well, I know I have to figure out the naming convention/transitioninging scheme.

I think it is somehow linked to the same scheme as is used for the vcf format (contact - info files).

Well, all in all, this is very interesting, and I hope to have time in the near future to follow up on the matter, as lots of the stuff I write will benefit from being put into calendar files, as do a lot of other stuff too, that is of general interest.

I wonder first of all, what happens if the calender is already there, does the events getting added once more, or are the former, totally removed, or are just unique elements added. That is things I want to investigate.

Better get back to the planetary motions for now. :slight_smile:

Anyways: is there any information you lack, then I’d suggest you’d have a look at Calendar and Contacts for Mac Os X server, as there you’ll find information for the Server side of those Applications.

Edit

There is also a program named iCal buddy, that is a command -line tool for interacting with iCal at least, that is made by hhas among others. The source code should be available.

Good Luck with your endeavours and efforts kel! :slight_smile:

Hi.

I think that properties beginning with “X-” are defined by an application for its own use, but I’m not sure. It wouldn’t hurt to include the ones that iCal/Calendar uses if you intend to import the calendar to it.

In my Calendar files, GMT/UTC dates and times (those followed by “Z”) are used only for administrative details such as creation and modification dates. Event dates and times are stored as per the time zone in which they were created. If the calendar’s opened on a computer set to a different time zone, iCal/Calendar will display the events at the local times corresponding to those instants. (This may depend on whether or not time zone support is turned on in the application’s preferences, but I can’t test it at the moment.)

Event dates which don’t have times or time zones are all-day events and are taken as lasting all day in whichever time zone they’re viewed.

Hi everybody,

The rfc page lists the definition as ‘x-name’, but doesn’t give examples of these experimental properties.

I think I’ve found how Calendar uses the X-WR-TIMEZONE property. Need to do more tests later, but here’s the scenario on my simple calendar file. Firstly, here’s the simple file which I changed a little:

When this is imported into Calendar, it is split into two calendar files. Note that in the second event Calendar DTStart is in utc. To every event an invisible alarm is added probably for Notification Center and the utc time remains. Here’s the newly created calendar file:

Note that DTStart is still in utc. So Calendar must change that time at run time for display.

Now for the good part. I created a new event in calendar “OurMeetings”. It seems that Calendar uses the timezone name to create the new event. Here’s the new event:

Calendar seems to use the ‘X-WR-TIMEZONE:Pacific/Honolulu’ in DTSTART for the new event. I was thinking that Calendar might want to know this information, if the user changes timezones. I still need to check if Calendar is really using theX-WR-TIMEZONE information or getting it from the system as some people do. :slight_smile:

I think I should import the simple calendar file with all the information that is need from the file. It would probably take too long to script Calendar to create 730 individual calendar file events, than to have it import the whole simple calendar.

Hope I’m not too far off. :smiley: Getting there.

Thanks a lot,
kel

I edited the time zone in the simple file to “X-WR-TIMEZONE:US/Pacific” and reimported it. Creating the new event shows that Calendar gets the timezone name from the system.

So, it still seems that the X-WR-TIMEZONE is not used. Think it’s best to write the times in this form as Calendar did.

It’s getting close to 1:00 PM. Need to check out what will happen in Notification Center.

Later,
kel

Here’s the basic simple file I ended up with:

If the time is in utc, then use the form of the second event. Otherwise, add the timezone name as in the first event. I left the X-WR-TIMEZONE just in case Calendar uses it for some reason.

Edited: one more thing. Linefeeds must be changed to returns in the ics file or else Calendar can’t read it.

Thanks a lot,
kel

Hi kel.

I imported your calendar into Calendar here, choosing the “New calendar” option. A new calendar was created with the name specified in the file and with events at 18:10 and 19:01 BST on 10th of this month ” so it works OK. I got exactly the same event times when I did it again with time zone support turned off.

Linefeeds in the file are fine on my machine.

Edit: Addendum. When I actually open the events, the times shown inside are BST when time zone support’s turned off and the originals ” along with notes of the times zones ” when it’s turned on.

Hi Nigel,

So, Calendar adjusts for the timezone change. Great!

Thanks for testing that,
kel

Hi Nigel,

What you’re saying is that the notes are added to the Calendar ics files noting changes in the timezone?

Here’s a short script to create the file from text if anyone is interested:

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
'"
do shell script "echo " & t & " | " & cmd -- & " >~/Desktop/TestCal.ics" -- write to file

Uncomment the last line to write to file. I haven’t tested the resulting ics file yet with actual times. Need to take a nap. I’ll fix it up tomorrow.

Edited: the script. fixed the comment for writing to file.

Edited: this script doesn’t work for me. I think I need another way to write the text to file. Not sure.

gl,
kel