ri_cal 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +3 -0
- data/lib/ri_cal.rb +1 -1
- data/lib/ri_cal/component/t_z_info_timezone.rb +26 -10
- data/ri_cal.gemspec +2 -2
- data/spec/ri_cal/component/t_z_info_timezone_spec.rb +25 -2
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
=== 0.6.3 - 14 June 2009
|
2
|
+
* Fixed http://rick_denatale.lighthouseapp.com/projects/30941-ri_cal/tickets/13
|
3
|
+
tzinfotimezones-with-no-transitions-fail-on-export
|
1
4
|
=== 0.6.2 - 11 June 2009
|
2
5
|
* Fixed http://rick_denatale.lighthouseapp.com/projects/30941-ri_cal/tickets/12
|
3
6
|
export-failure-for-unbounded-tzinfo-timezone
|
data/lib/ri_cal.rb
CHANGED
@@ -14,7 +14,7 @@ module RiCal
|
|
14
14
|
autoload :OccurrenceEnumerator, "#{my_dir}/ri_cal/occurrence_enumerator.rb"
|
15
15
|
|
16
16
|
# :stopdoc:
|
17
|
-
VERSION = '0.6.
|
17
|
+
VERSION = '0.6.3'
|
18
18
|
LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
|
19
19
|
PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
|
20
20
|
|
@@ -2,21 +2,31 @@
|
|
2
2
|
#
|
3
3
|
# A wrapper class for a Timezone implemented by the TZInfo Gem
|
4
4
|
# (or by Rails)
|
5
|
+
#
|
6
|
+
|
5
7
|
class RiCal::Component::TZInfoTimezone < RiCal::Component::Timezone
|
6
8
|
|
7
9
|
class Period #:nodoc: all
|
8
10
|
|
9
11
|
def initialize(which, this_period, prev_period)
|
10
12
|
@which = which
|
11
|
-
@onset = this_period
|
12
|
-
|
13
|
+
@onset = period_local_start(this_period)
|
14
|
+
if prev_period
|
15
|
+
@offset_from = format_rfc2445_offset(prev_period.utc_total_offset)
|
16
|
+
else
|
17
|
+
@offset_from = format_rfc2445_offset(this_period.utc_total_offset)
|
18
|
+
end
|
13
19
|
@offset_to = format_rfc2445_offset(this_period.utc_total_offset)
|
14
20
|
@abbreviation = this_period.abbreviation
|
15
21
|
@rdates = []
|
16
22
|
end
|
23
|
+
|
24
|
+
def period_local_start(period)
|
25
|
+
(period.local_start || DateTime.parse("16010101T000000")).strftime("%Y%m%dT%H%M%S")
|
26
|
+
end
|
17
27
|
|
18
28
|
def add_period(this_period)
|
19
|
-
@rdates << this_period
|
29
|
+
@rdates << period_local_start(this_period)
|
20
30
|
end
|
21
31
|
|
22
32
|
|
@@ -44,6 +54,10 @@ class RiCal::Component::TZInfoTimezone < RiCal::Component::Timezone
|
|
44
54
|
def initialize
|
45
55
|
@dst_period = @std_period = @previous_period = nil
|
46
56
|
end
|
57
|
+
|
58
|
+
def empty?
|
59
|
+
@periods.nil? || @periods.empty?
|
60
|
+
end
|
47
61
|
|
48
62
|
def daylight_period(this_period, previous_period)
|
49
63
|
@daylight_period ||= Period.new("DAYLIGHT", this_period, previous_period)
|
@@ -57,9 +71,9 @@ class RiCal::Component::TZInfoTimezone < RiCal::Component::Timezone
|
|
57
71
|
@periods ||= []
|
58
72
|
@periods << period unless @periods.include?(period)
|
59
73
|
end
|
60
|
-
|
61
|
-
def add_period(this_period)
|
62
|
-
if @previous_period
|
74
|
+
|
75
|
+
def add_period(this_period, force=false)
|
76
|
+
if @previous_period || force
|
63
77
|
if this_period.dst?
|
64
78
|
period = daylight_period(this_period, @previous_period)
|
65
79
|
else
|
@@ -81,7 +95,7 @@ class RiCal::Component::TZInfoTimezone < RiCal::Component::Timezone
|
|
81
95
|
def initialize(tzinfo_timezone) #:nodoc:
|
82
96
|
@tzinfo_timezone = tzinfo_timezone
|
83
97
|
end
|
84
|
-
|
98
|
+
|
85
99
|
# convert time from this time zone to utc time
|
86
100
|
def local_to_utc(time)
|
87
101
|
@tzinfo_timezone.local_to_utc(time.to_ri_cal_ruby_value)
|
@@ -110,13 +124,15 @@ class RiCal::Component::TZInfoTimezone < RiCal::Component::Timezone
|
|
110
124
|
def export_utc_to(export_stream, utc_start, utc_end) #:nodoc:
|
111
125
|
export_stream.puts "BEGIN:VTIMEZONE","TZID;X-RICAL-TZSOURCE=TZINFO:#{identifier}"
|
112
126
|
periods = Periods.new
|
113
|
-
period = tzinfo_timezone.period_for_utc(utc_start)
|
127
|
+
period = initial_period = tzinfo_timezone.period_for_utc(utc_start)
|
114
128
|
#start with the period before the one containing utc_start
|
115
|
-
|
116
|
-
|
129
|
+
prev_period = period.utc_start && tzinfo_timezone.period_for_utc(period.utc_start - 1)
|
130
|
+
period = prev_period if prev_period
|
131
|
+
while period && period.utc_start && period.utc_start < utc_end
|
117
132
|
periods.add_period(period)
|
118
133
|
period = period.utc_end && tzinfo_timezone.period_for_utc(period.utc_end + 1)
|
119
134
|
end
|
135
|
+
periods.add_period(initial_period, :force) if periods.empty?
|
120
136
|
periods.export_to(export_stream)
|
121
137
|
export_stream.puts "END:VTIMEZONE\n"
|
122
138
|
end
|
data/ri_cal.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{ri_cal}
|
5
|
-
s.version = "0.6.
|
5
|
+
s.version = "0.6.3"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["author=Rick DeNatale"]
|
9
|
-
s.date = %q{2009-06-
|
9
|
+
s.date = %q{2009-06-14}
|
10
10
|
s.default_executable = %q{ri_cal}
|
11
11
|
s.description = %q{A new Ruby implementation of RFC2445 iCalendar.
|
12
12
|
|
@@ -1,8 +1,9 @@
|
|
1
1
|
#- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
|
2
2
|
|
3
3
|
require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
|
4
|
-
|
5
|
-
require '
|
4
|
+
# Uncomment the next two lines to run this spec in textmate
|
5
|
+
# require 'rubygems'
|
6
|
+
# require 'tzinfo'
|
6
7
|
|
7
8
|
describe RiCal::Component::TZInfoTimezone do
|
8
9
|
|
@@ -33,4 +34,26 @@ END:STANDARD
|
|
33
34
|
END:VTIMEZONE
|
34
35
|
ENDDATA
|
35
36
|
end
|
37
|
+
|
38
|
+
TZInfo::Timezone.all_identifiers.each do |tz|
|
39
|
+
context "TZInfo timezone #{tz}" do
|
40
|
+
before(:each) do
|
41
|
+
@calendar = RiCal.Calendar do |cal|
|
42
|
+
cal.event do |event|
|
43
|
+
event.description = "test"
|
44
|
+
event.dtstart = "TZID=#{tz}:20090530T123000"
|
45
|
+
event.dtend = "TZID=#{tz}:20090530T123001"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
it "should be allowed as a tzid" do
|
50
|
+
lambda {@calendar.export}.should_not raise_error
|
51
|
+
end
|
52
|
+
unless tz == "UTC"
|
53
|
+
it "should produce at least one period in the VTIMEZONE" do
|
54
|
+
@calendar.export.should match(/BEGIN:(STANDARD|DAYLIGHT)/)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
36
59
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ri_cal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- author=Rick DeNatale
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06-
|
12
|
+
date: 2009-06-14 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|