From pic at superfluo.org Sun Jan 7 17:17:41 2007 From: pic at superfluo.org (Nicola Piccinini) Date: Sun, 07 Jan 2007 23:17:41 +0100 Subject: [TZInfo-users] timezones, periods and utc_offset Message-ID: <45A17185.3090702@superfluo.org> Hi all, sorry for the silly question: is the result of tz.current_period.offset.utc_offset constant over time? In other words: is it independent from the current period? (as I suppose) Thanks. -- Nicola Piccinini -- http://superfluo.org From phil.ross at gmail.com Sun Jan 7 19:00:48 2007 From: phil.ross at gmail.com (Philip Ross) Date: Mon, 8 Jan 2007 00:00:48 +0000 Subject: [TZInfo-users] timezones, periods and utc_offset In-Reply-To: <45A17185.3090702@superfluo.org> References: <45A17185.3090702@superfluo.org> Message-ID: <4ac540410701071600p63619230w4f0eadadae122f2@mail.gmail.com> On 07/01/07, Nicola Piccinini wrote: > sorry for the silly question: > is the result of > tz.current_period.offset.utc_offset > constant over time? > In other words: is it independent from the current period? (as I suppose) I don't think its a silly question - the documentation could do with some improvements. utc_offset is the base offset from UTC. For example, Europe/Rome is at UTC + 1 hour and America/New_York is at UTC - 5 hours. std_offset is the offset to the usually observed time as given by utc_offset. It will typically vary between 0 and +1 hour according to daylight savings. utc_total_offset is utc_offset + std_offset. utc_offset tends to stay constant over time. It won't necessarily remain the same across all periods though because countries sometimes redefine their timezones. It's also worth noting that you should be using tz.current_period.utc_offset rather than tz.current_period.offset.utc_offset. start_transition, end_transition and offset shouldn't really be publicly available and may be removed in a future release. -- Phil Ross http://tzinfo.rubyforge.org/ -- DST-aware timezone library for Ruby From brandon at opensoul.org Tue Jan 9 00:50:12 2007 From: brandon at opensoul.org (Brandon Keepers) Date: Tue, 9 Jan 2007 00:50:12 -0500 Subject: [TZInfo-users] using TZInfo to generate iCalendar VTIMEZONE Message-ID: I'm working on a CalDAV client for Ruby, and part of the icalendar specification requires that you define any timezones that you you use. From what I've gathered, this timezone definition should include all the rules for dates in the icalendar file. So, if I have dates spanning from Jan 2006 - June 2007, then I would need to include 4 rules, the old standard and daylight times, and the new standard and daylight times. Here is an example of the timezone definition: BEGIN:VCALENDAR PRODID:-//Example Corp.//CalDAV Client//EN VERSION:2.0 BEGIN:VTIMEZONE TZID:US-Eastern LAST-MODIFIED:19870101T000000Z BEGIN:STANDARD DTSTART:19671029T020000 RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10 TZOFFSETFROM:-0400 TZOFFSETTO:-0500 TZNAME:Eastern Standard Time (US & Canada) END:STANDARD BEGIN:DAYLIGHT DTSTART:19870405T020000 RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4 TZOFFSETFROM:-0500 TZOFFSETTO:-0400 TZNAME:Eastern Daylight Time (US & Canada) END:DAYLIGHT END:VTIMEZONE END:VCALENDAR If possible, I would like to use TZInfo to get this information. From what I can tell, this data is available in TZInfo, but it is not accessible through the API. Could someone give me some pointers on how to get all "active" timezone periods for a given date (standard & daylight), and all timezone periods for a given date range? Thanks, Brandon -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 186 bytes Desc: This is a digitally signed message part Url : http://rubyforge.org/pipermail/tzinfo-users/attachments/20070109/a4a7d622/attachment.bin From phil.ross at gmail.com Tue Jan 9 09:23:20 2007 From: phil.ross at gmail.com (Philip Ross) Date: Tue, 9 Jan 2007 14:23:20 +0000 Subject: [TZInfo-users] using TZInfo to generate iCalendar VTIMEZONE In-Reply-To: References: Message-ID: <4ac540410701090623u69b47205h62dfd5848f36ad14@mail.gmail.com> On 09/01/07, Brandon Keepers wrote: > I'm working on a CalDAV client for Ruby, and part of the icalendar > specification requires that you define any timezones that you you > use. From what I've gathered, this timezone definition should > include all the rules for dates in the icalendar file. So, if I have > dates spanning from Jan 2006 - June 2007, then I would need to > include 4 rules, the old standard and daylight times, and the new > standard and daylight times. You might be interested in a C program called Vzic (http://dialspace.dial.pipex.com/prod/dialspace/town/pipexdsl/s/asbm26/vzic/). This program takes the source data from http://www.twinsun.com/tz/tz-link.htm (that TZInfo also uses) and produces a set of iCalendar VTIMEZONE files. > If possible, I would like to use TZInfo to get this information. > From what I can tell, this data is available in TZInfo, but it is > not accessible through the API. Could someone give me some pointers > on how to get all "active" timezone periods for a given date > (standard & daylight), and all timezone periods for a given date range? There will only be one timezone period active for any UTC datetime. There can be zero or more active for a local datetime. The methods Timezone#period_for_utc and Timezone#periods_for_local can be used to obtain TimezonePeriods for a given time. You could then use the TimezonePeriod#(utc|local)_(start|end) methods to scan forward or back to find other periods. When packaging a TZInfo release, the source data is read and converted (by TZInfo::TZDataParser) into a set of transitions for each zone - one transition for each time the offset to UTC or zone name changes. You can access this data, but not through the public interface (so this may not work in future releases): module TZInfo class DataTimezoneInfo attr_reader :transitions end end tz = TZInfo::Timezone.get('Europe/London') transitions = tz.send(:info).transitions transitions will be an array of TimezoneTransitionInfo classes. See the source for timezone_transition_info.rb (http://rubyforge.org/viewvc/trunk/tzinfo/lib/tzinfo/timezone_transition_info.rb?revision=125&root=tzinfo&view=markup) to see the available methods. This will only work on 'data' timezones (tz.kind_of?(TZInfo::DataTimezone)). Many of the zones are 'linked' (essentially symbolic links to other zones). You can find the linked to timezone by adding a attr_reader to the LinkedTimezone class: module TZInfo class LinkedTimezone attr_reader :linked_timezone end end tz = TZInfo::Timezone.get('GB-Eire').linked_timezone transitions = tz.send(:info).transitions I hope this has been of some help to you. Please let me know if you have any further questions. -- Phil Ross http://tzinfo.rubyforge.org/ -- DST-aware timezone library for Ruby