Hello all, I am currently evaluating the vpim libraries and like them very much. However there''s one thing I can''t get done: How can I set the TZID parameter for DTSTART/END dates so my encoded ICS file looks something like this: BEGIN:VEVENT ... DTSTART;TZID=Eastern Time:20071201T080000 DTEND;TZID=Eastern Time:20071207T110000 ... END:VEVENT I managed to create the VTIMEZONE object, but that only sets up the time-zone itself for reference. To actually use it, I need the TZID thing. UTC does not help me much ''caus I still need to tell the calendar in which time-zone the event happens so it can calculate the local time. I found that I can create fields manually like this: f = Vpim::DirectoryInfo::Field.create(''DTSTART'', "20071201T080000", "TZID"=>"Eastern Time") f.to_s => "DTSTART;TZID=Eastern Time:20071201T080000\n" That''s exactly the format I need. Then again I did not find out how to properly add that to the event object (i.e. event.dtstart(time, {"key" => "value"}) does not work). This led me to monkey-patch the code (see below). I''m not deep into it and don''t get quite the structure of the code yet. So even the patch works in my setting, it could screw things. I am grateful for any hints and pointers for an official way of adding the TZID parameter to date/time fields. Andreas --- i''m a monkeeey --- module Vpim::Icalendar::Set::Util alias :original_set_date_or_datetime :set_date_or_datetime def set_date_or_datetime(name, default, value, params = {}) props = original_set_date_or_datetime(name, default, value) params.each { |k,v| props.field(name)[k] = v } props end end module Vpim::Icalendar::Set::Common def dtstart(start, params = {}) set_date_or_datetime ''DTSTART'', ''DATE-TIME'', start, params self end end class Vpim::Icalendar::Vevent::Maker def dtend(dtend, params = {}) set_date_or_datetime ''DTEND'', ''DATE-TIME'', dtend, params end end
Quoting monodeck at googlemail.com, on Wed, Feb 07, 2007 at 05:40:16PM +0100:> However there''s one thing I can''t get done: How can I set the TZID > parameter for DTSTART/END dates so my encoded ICS file looks > something like this: > > BEGIN:VEVENT > ... > DTSTART;TZID=Eastern Time:20071201T080000 > DTEND;TZID=Eastern Time:20071207T110000 > ... > END:VEVENTI''ve never used timezones, or set tzids, so there is no API for them. But, I''m painfully aware that TZ support is not good in vPim. Since I started working on it, several very nice timezone/date support packages with compiled in tz info have appeared on ruby forge. Your approach seems completely workable. Do you think a full params hash is required? It appears only ;tzid can be set (other than ;value, which should be set already, and the magic hole, x- params). Doesn''t a TZID have to map to a VTIMEZONE present in a calendar, to be correctly encoded? Perhaps instead of a string, a Vtimezone object could be passed: module Vpim::Icalendar::Set::Common def dtstart(start, timezone = nil) end end And if there was an Icalendar#tz(tzid = nil) # nil means the single one, raise if there isn''t one You could do cal.add_event(start, cal.tz) do |e| # event in the default timezone ... end cal.add_event(start) do |e| # event in "floating" time ... end Just throwing ideas out, you''re the user, and the implementor, I''m afraid. Time spent on vPim has become a time sink I can''t afford, sorry. If you like, I can arrange commit access. Cheers, Sam
Hey Sam,> > However there''s one thing I can''t get done: How can I set the TZID > I''ve never used timezones, or set tzids, so there is no API for them.I see. I''ve finally switchted to templates for generating calendar files. I found it''s the quickest approach for my needs at the moment (I don''t need parsing, but a lot of extra dirty X Outlook fields and tweaks). Time zones however are very essential in my case since people importing the ICS files are not in the same time zone.> But, I''m painfully aware that TZ support is not good in vPim. Since I > started working on it, several very nice timezone/date support packages > with compiled in tz info have appeared on ruby forge.I''m not sure if it sould go as far as having a "real" time zone support (involving other libs). In my case i''d only need to say like: "Dates and times for vevent x to be interpreted as local time in time-zone y". So I''d be happy just having the API for supporting VTIMEZONE and TZID wherever I need it.> Do you think a full params hash is required? It appears only ;tzid can be set > (other than ;value, which should be set already, and the magic hole, x- params).If it''s constrained that way, the API shoudl reflect it of course.> Just throwing ideas out, you''re the user, and the implementor, I''m > afraid. Time spent on vPim has become a time sink I can''t afford, > sorry. If you like, I can arrange commit access.Same here. I need a day that counts 48 hours, then I would have OpenSource time again. But i''ll send you a patch along as soon as the "tempalte" approach gets to awkward and I need somthing more contained. Thanks you took the time to answer. Andreas