イベントが夏時間と標準時間の切り替えをまたがる場合の振舞
→関連クラス図 12.時間参照系
require 'when_exe' include When
-- NewYork.ics -- (使用する場合は行頭の空白を削除) BEGIN:VCALENDAR VERSION:2.0 PRODID:-//hacksw/handcal//NONSGML v1.0//EN BEGIN:VTIMEZONE TZID:America/New_York LAST-MODIFIED:20050809T050000Z BEGIN:STANDARD DTSTART:19671029T020000 RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU;UNTIL=20061029T060000Z TZOFFSETFROM:-0400 TZOFFSETTO:-0500 TZNAME:EST END:STANDARD BEGIN:DAYLIGHT DTSTART:19870405T020000 RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=1SU;UNTIL=20060402T070000Z TZOFFSETFROM:-0500 TZOFFSETTO:-0400 TZNAME:EDT END:DAYLIGHT END:VTIMEZONE END:VCALENDAR ----------------
vcal = Resource("NewYork.ics") # "NewYork.ics"をメモリに読み込む p [vcal.class, vcal.iri] #=> [When::V::Calendar, "NewYork.ics"] tz = vcal["America/New_York"] p [tz.class, tz.iri] #=> [When::V::Timezone, "NewYork.ics::America/New_York"]
When::V::Event.new({ 'rrule' => 'FREQ=YEARLY;BYMONTH=4;BYDAY=1SU;BYHOUR=1,2,3,4;BYMINUTE=30;COUNT=4', 'dtstart' => 'TZID=America/New_York:19970406T013000' }).each do |date| p date #=> 1997-04-06T01:30:00-05:00, 1997-04-06T03:30:00-04:00, 1997-04-06T04:30:00-04:00, 1998-04-05T01:30:00-05:00 end
When::V::Event.new({ 'rrule' => 'FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU;BYHOUR=1,2,3;BYMINUTE=30;COUNT=4', 'dtstart' => 'TZID=America/New_York:19971026T013000' }).each do |date| p date #=> 1997-10-26T01:30:00-04:00, 1997-10-26T02:30:00-05:00, 1997-10-26T03:30:00-05:00, 1998-10-25T01:30:00-04:00 end
When::V::Event.new({ 'rrule' => 'FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU;BYHOUR=1,1=,2,3;BYMINUTE=30;COUNT=5', 'dtstart' => 'TZID=America/New_York:19971026T013000' }).each do |date| p date #=> 1997-10-26T01:30:00-04:00, 1997-10-26T01:30:00-05:00, 1997-10-26T02:30:00-05:00, 1997-10-26T03:30:00-05:00, 1998-10-25T01:30:00-04:00 end
BYHOUR=1,1=,2,3 の 1= は When.exe Standard Expression の書式に準じている
When::V::Event.new({ 'rrule' => 'FREQ=YEARLY;BYMONTH=4;BYDAY=1SU;BYHOUR=1,2,3,4;BYMINUTE=30;COUNT=4', 'dtstart' => 'TZID=America/Chicago:19970406T013000' }).each do |date| p date #=> 1997-04-06T01:30:00-06:00, 1997-04-06T03:30:00-05:00, 1997-04-06T04:30:00-05:00, 1998-04-05T01:30:00-06:00 end
When::V::Event.new({ 'rrule' => 'FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU;BYHOUR=1,2,3;BYMINUTE=30;COUNT=4', 'dtstart' => 'TZID=America/Chicago:19971026T013000' }).each do |date| p date #=> 1997-10-26T01:30:00-05:00, 1997-10-26T02:30:00-06:00, 1997-10-26T03:30:00-06:00, 1998-10-25T01:30:00-05:00 end
When::V::Event.new({ 'rrule' => 'FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU;BYHOUR=1,1=,2,3;BYMINUTE=30;COUNT=5', 'dtstart' => 'TZID=America/Chicago:19971026T013000' }).each do |date| p date #=> 1997-10-26T01:30:00-05:00, 1997-10-26T01:30:00-06:00, 1997-10-26T02:30:00-06:00, 1997-10-26T03:30:00-06:00, 1998-10-25T01:30:00-05:00 end
制限 : BYHOUR=1= から生成した 1997-10-26T01:30:00-06:00 が保持する時間帯は -06:00 固定となり加減算しても変わらない。