Blythe Dunham
2006-Mar-16 11:17 UTC
[iCalendar-devel] Resend: [Fwd: Problems with timezone in generated ical files]
Heya, I was considering modifying the String#to_cal to support non-ascii data as suggested below. However, since \n is a special character in iCalendar format, I discovered that some parsers choke on the carriage returns that were generated. I was considering replacing them with "\\n" or " " to avoid this. Do you foresee any other problems with this? Perhaps I should convert some other characters as well.> class String > def to_ical+ self.to_s.gsub("\n", "\\n")> - "#{self.dump[1...-1]}" > - "#{self}" > end > endOriginally I was considering dumping everything except for the multibyte characters, but then \t (tab) appears as \t in my files. self.unpack("U*").collect {|s| (s > 127 ? [s].pack("U*") : s.chr.dump[1...-1])}.join("") -Blythe On Mon, 2006-01-09 at 00:20 +0100, Gitte Wange wrote:> Jeff Rose wrote: > > Whoops, I thought I responded before... This is because the Timezone is > > being specified as a parameter of the DTSTART property, and I think I > > screwed up the parameter handling. I''ve been out on holidays, but I''m > > back now and I''ll spend this week working on projects. I''d surely > > accept patches too :-) > > Hope you had a nice vacation :-) > > Well I''d be happy to supply patches, but I''m having some trouble finding > my way around the code.Cool. I''ve put in your patch. I don''t remember why I had the sort of odd dump there (should have put a comment), but for now we can go with what you have. If you could send me a unit test or at least a piece of code that breaks the old version that would be great. I''m trying to write a test each time someone finds a new bug so I make sure it stays fixed... As for the parameter stuff, I can give you a better description now that I''ve looked over it again, and maybe you can help with ideas or a patch or both... Currently the parser is parsing parameters and the generator spits them back out when printing. They are stored per property in a hash (@property_params) in the Component class. Basically everything is ready to support parameters in the API except for the API itself that just sets the hash value. So if we can figure out how the API should look then it should be very quick to implement what''s needed. Using your DTSTART property as an example, we just need to decide on at least an initial attempt at a good parameter API. So currently you do something like: myevent.start = Date.today Now we need to add something for the timezone parameter. This should probably be generic so that any arbitrary property can work. How about this for starters: myevent.start = Date.today, "TZID", "Europe/Copenhagen" Where the first item is always the value, the second if it exists is a parameter, and the rest if they exist are parameter values. Or we could use a hash: myevent.start = Date.today, {:param = "TZID", :val "Europe/Copenhagen"} I think I like the hash better... What do you think? Either way it would just be a small addition to the generators ical_property and ical_multi_property so I can maybe even get it done today.> Although I have a patch for you for the conversions.rb (String class) > because I had some problems with encoding and danish characters (I have > attached it to this mail). > I''m not sure why the String class printed the way it did, but it worked > very badly with unicode characters. > > I would love to help out improving this module, but the TZID problem I > have not yet found a solution for :-( > > Greetings, > Gitte WangeIf you want to look at it you can look at parser.rb to see how it parses parameters into the @property_params and component.rb to see it print those parameters. Component.ical_property is a method generator that is used for all the properties that have a single instance, and Component.ical_multi_property is a generator for properties that have multiple instances. If you look at components/event.rb you can see how they are used. Ciao, Jeff> plain text document attachment (conversions.rb.patch) > --- conversions.rb.orig Thu Dec 1 00:46:49 2005 > +++ conversions.rb Wed Dec 28 23:41:21 2005 > @@ -20,7 +20,7 @@ > > class String > def to_ical > - "#{self.dump[1...-1]}" > + "#{self}" > end > end >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/icalendar-devel/attachments/20060316/cb5a229f/attachment-0001.htm