[TZInfo-users] vtimezone with tzinfo
phil.ross at gmail.com
Tue Jul 8 17:11:35 EDT 2008
2008/7/8 Dusty Doris <tzinfo at dusty.name>:
> I found an old post talking about using tzinfo to create vcalendar
> files and I was wondering if anyone ever got this working.
I'm not aware of anyone having built anything that does this.
> I tried using the modules in this post as described and was able to
> view the transition information, unfortunately, I just don't
> understand what I'm looking at yet. Using the 'America/New_York'
> timezone, the transitions array had 262 objects in it. I'm not really
> sure how to translate that into what I need for a vtimezone.
Each transition represents either the change between standard and
daylight savings time or a change in the offset of local time to UTC.
For example, using 'America/New_York', transition 176 represents the
change to daylight savings (+3600 seconds) with a local time offset
from UTC of -5 hours (-18000) seconds. Transition 177 is the change
back to standard time:
>> tz = TZInfo::Timezone.get('America/New_York')
=> #<TZInfo::DataTimezone: America/New_York>
=> Sun Mar 09 07:00:00 UTC 2008
=> #<TZInfo::TimezoneOffsetInfo: -18000,3600,EDT>
=> Sun Nov 02 06:00:00 UTC 2008
=> #<TZInfo::TimezoneOffsetInfo: -18000,0,EST>
I'm not familiar with the VTIMEZONE format, but from a brief look at
the specification I would expect that it would be possible to use the
transitions and output an RDATE property for each. You would have to
have separate DAYLIGHT and STANDARD sections for each time the offset
from UTC is different. You should be able to omit transitions that
aren't of use (i.e. fall outside the range of dates you are handling).
> I have also taken a look at Vzic and will most likely be using that,
> however, if I can find a way to do this using tzinfo instead, I'd love
> to go that route. But, if its just not worth my time, I'll take that
> as a helpful suggestion as well!
Vzic produces a more concise file because it can use the RRULE
properties instead of RDATE.
TZInfo and Vzic use the same source of data
(http://www.twinsun.com/tz/tz-link.htm). This consists of rules like
'change to standard time at 2am on the first Sunday of November from
When Vzic produces a VTIMEZONE file it can translate these rules into
RRULE properties. In TZInfo, the rules have been used at compile time
to work out every transition in advance.
> What I would like to do, is generate an ics file from my calendar and
> insert the appropriate vcalendar part depending on the timezone the
> user is in.
> So, if my user elected 'America/New_York', then I'd like to be able to
> inject this into the ics file.
> I got that from the Vzic output.
You may like to note that the output you have there is not completely
accurate. It is using the 2007 and later US daylight saving rules but
stating that they apply from 1970 onwards. To get the complete data
from Vzic run it with the --pure option.
> Can anyone give a beginner in timezones a hint on how to do this with
> tzinfo? Or, do you think it would just be easier to write a
> bash/sed/awk/ruby script that can simply populate a database with the
> content in the Vzic files?
I think the easiest option would be to use Vzic and capture the
content. For compatibility with TZInfo, make sure you run Vzic against
the same version of the Olson tz database as TZInfo was built from
(see the CHANGES file:
http://tzinfo.rubyforge.org/ -- DST-aware timezone library for Ruby
More information about the TZInfo-users