icalendar 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +5 -0
- data/lib/icalendar/base.rb +1 -1
- data/lib/icalendar/calendar.rb +14 -0
- data/lib/icalendar/component.rb +2 -2
- data/lib/icalendar/component/alarm.rb +1 -0
- data/lib/icalendar/parser.rb +1 -0
- data/lib/icalendar/tzinfo.rb +56 -37
- data/test/fixtures/folding.ics +1 -1
- data/test/test_conversions.rb +1 -1
- data/test/test_tzinfo.rb +32 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 370af2e2d4636f906480c2a2d9faa6f71d00c572
|
4
|
+
data.tar.gz: a9bf492ff26c0d75dbe138f2a08841910882105d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f73cd84ce78cb0c7bc9cb5c65a08de0c09d1cffe087ad5b9b17ef92e6ad32e0f470b23ecd53255d99198e7fd980a9eac28b317574adca005bada4294001201b
|
7
|
+
data.tar.gz: a3fae6aef26214cda39e5974cc9c38556a4626a2aff24af82a5310319a76dd79cc7f18a3cc46e093b37c809664f9ec99b694e237b06d2f3d1a88b216d58f4b93
|
data/History.txt
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
=== 1.4.0 2013-05-21
|
2
|
+
* Implement ACKNOWLEDGED property for VALARM - tsuzuki08
|
3
|
+
* Output VERSION property as first line after BEGIN:VCALENDAR
|
4
|
+
* Check for unbounded timezone transitions in tzinfo
|
5
|
+
|
1
6
|
=== 1.3.0 2013-03-31
|
2
7
|
* Lenient parsing mode ignores unknown properties - David Grandinetti
|
3
8
|
* VTIMEZONE positive offsets properly have "+" prepended (Fixed issue
|
data/lib/icalendar/base.rb
CHANGED
data/lib/icalendar/calendar.rb
CHANGED
@@ -25,6 +25,20 @@ module Icalendar
|
|
25
25
|
self.version = "2.0" # Version of the specification
|
26
26
|
end
|
27
27
|
|
28
|
+
def print_component
|
29
|
+
"BEGIN:#{@name.upcase}\r\n" +
|
30
|
+
"VERSION:#{version}\r\n" +
|
31
|
+
|
32
|
+
# Then the properties
|
33
|
+
print_properties(@properties.select { |k,v| k != 'version' }) +
|
34
|
+
|
35
|
+
# sub components
|
36
|
+
yield +
|
37
|
+
|
38
|
+
# End of this component
|
39
|
+
"END:#{@name.upcase}\r\n"
|
40
|
+
end
|
41
|
+
|
28
42
|
def event(&block)
|
29
43
|
e = Event.new
|
30
44
|
# Note: I'm not sure this is the best way to pass this down, but it works
|
data/lib/icalendar/component.rb
CHANGED
@@ -125,10 +125,10 @@ module Icalendar
|
|
125
125
|
"END:#{@name.upcase}\r\n"
|
126
126
|
end
|
127
127
|
|
128
|
-
def print_properties
|
128
|
+
def print_properties(properties = @properties)
|
129
129
|
s = ""
|
130
130
|
|
131
|
-
|
131
|
+
properties.sort.each do |key,val|
|
132
132
|
# Take out underscore for property names that conflicted
|
133
133
|
# with built-in words.
|
134
134
|
if key =~ /ip_.*/
|
data/lib/icalendar/parser.rb
CHANGED
data/lib/icalendar/tzinfo.rb
CHANGED
@@ -47,75 +47,94 @@ module TZInfo
|
|
47
47
|
period = period_for_local(date)
|
48
48
|
timezone = Icalendar::Timezone.new
|
49
49
|
timezone.timezone_id = identifier
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
if period.start_transition.nil?
|
51
|
+
timezone.add period.single
|
52
|
+
elsif period.end_transition.nil?
|
53
|
+
timezone.add period.dst? ? period.daylight : period.standard
|
54
|
+
else
|
55
|
+
timezone.add period.daylight
|
56
|
+
timezone.add period.standard
|
57
|
+
end
|
58
|
+
timezone
|
53
59
|
end
|
54
60
|
end
|
55
61
|
|
56
62
|
class TimezoneTransitionInfo
|
57
63
|
def offset_from
|
58
|
-
|
59
|
-
sprintf("%+-2.2d%2.2d", (a / 3600).to_i, ((a / 60) % 60).to_i)
|
64
|
+
previous_offset.ical_offset
|
60
65
|
end
|
61
66
|
|
62
67
|
def offset_to
|
63
|
-
|
64
|
-
sprintf("%+-2.2d%2.2d", (a / 3600).to_i, ((a / 60) % 60).to_i)
|
68
|
+
offset.ical_offset
|
65
69
|
end
|
66
70
|
|
67
71
|
def rrule
|
68
72
|
start = local_start.to_datetime
|
69
73
|
# this is somewhat of a hack, but seems to work ok
|
70
74
|
[sprintf(
|
71
|
-
|
75
|
+
'FREQ=YEARLY;BYMONTH=%d;BYDAY=%d%s',
|
72
76
|
start.month,
|
73
77
|
((start.day - 1)/ 7).to_i + 1,
|
74
|
-
start.strftime(
|
78
|
+
start.strftime('%a').upcase[0,2]
|
75
79
|
)]
|
76
80
|
end
|
77
81
|
|
78
82
|
def dtstart
|
79
|
-
local_start.to_datetime.strftime
|
83
|
+
local_start.to_datetime.strftime '%Y%m%dT%H%M%S'
|
80
84
|
end
|
85
|
+
end
|
81
86
|
|
87
|
+
class TimezoneOffsetInfo
|
88
|
+
def ical_offset
|
89
|
+
o = utc_total_offset
|
90
|
+
sprintf '%+-2.2d%2.2d', (o / 3600).to_i, ((o / 60) % 60).to_i
|
91
|
+
end
|
82
92
|
end
|
83
93
|
|
84
94
|
class TimezonePeriod
|
85
95
|
def daylight
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
96
|
+
Icalendar::Daylight.new.tap do |day|
|
97
|
+
if dst?
|
98
|
+
day.timezone_name = abbreviation.to_s
|
99
|
+
day.timezone_offset_from = start_transition.offset_from
|
100
|
+
day.timezone_offset_to = start_transition.offset_to
|
101
|
+
day.dtstart = start_transition.dtstart
|
102
|
+
day.recurrence_rules = start_transition.rrule unless end_transition.nil?
|
103
|
+
else
|
104
|
+
day.timezone_name = abbreviation.to_s.sub("ST","DT")
|
105
|
+
day.timezone_offset_from = end_transition.offset_from
|
106
|
+
day.timezone_offset_to = end_transition.offset_to
|
107
|
+
day.dtstart = end_transition.dtstart
|
108
|
+
day.recurrence_rules = end_transition.rrule
|
109
|
+
end
|
99
110
|
end
|
100
|
-
return day
|
101
111
|
end
|
102
112
|
|
103
113
|
def standard
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
114
|
+
Icalendar::Standard.new.tap do |std|
|
115
|
+
if dst?
|
116
|
+
std.timezone_name = abbreviation.to_s.sub('DT', 'ST')
|
117
|
+
std.timezone_offset_from = end_transition.offset_from
|
118
|
+
std.timezone_offset_to = end_transition.offset_to
|
119
|
+
std.dtstart = end_transition.dtstart
|
120
|
+
std.recurrence_rules = end_transition.rrule
|
121
|
+
else
|
122
|
+
std.timezone_name = abbreviation.to_s
|
123
|
+
std.timezone_offset_from = start_transition.offset_from
|
124
|
+
std.timezone_offset_to = start_transition.offset_to
|
125
|
+
std.dtstart = start_transition.dtstart
|
126
|
+
std.recurrence_rules = start_transition.rrule unless end_transition.nil?
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def single
|
132
|
+
Icalendar::Standard.new.tap do |std|
|
112
133
|
std.timezone_name = abbreviation.to_s
|
113
|
-
std.timezone_offset_from =
|
114
|
-
std.timezone_offset_to =
|
115
|
-
std.dtstart =
|
116
|
-
std.recurrence_rules = start_transition.rrule
|
134
|
+
std.timezone_offset_from = offset.ical_offset
|
135
|
+
std.timezone_offset_to = offset.ical_offset
|
136
|
+
std.dtstart = DateTime.new(1970).strftime '%Y%m%dT%H%M%S'
|
117
137
|
end
|
118
|
-
return std
|
119
138
|
end
|
120
139
|
end
|
121
140
|
end
|
data/test/fixtures/folding.ics
CHANGED
data/test/test_conversions.rb
CHANGED
data/test/test_tzinfo.rb
CHANGED
@@ -7,8 +7,8 @@ require 'icalendar/tzinfo'
|
|
7
7
|
|
8
8
|
class TestTZInfoExt < Test::Unit::TestCase
|
9
9
|
def setup
|
10
|
-
tz = TZInfo::Timezone.get
|
11
|
-
@timezone = tz.ical_timezone
|
10
|
+
tz = TZInfo::Timezone.get 'Europe/Copenhagen'
|
11
|
+
@timezone = tz.ical_timezone DateTime.new(1970)
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_daylight_offset
|
@@ -24,4 +24,34 @@ class TestTZInfoExt < Test::Unit::TestCase
|
|
24
24
|
assert_equal "+0200", tz_offset_from
|
25
25
|
assert_equal "+0100", tz_offset_to
|
26
26
|
end
|
27
|
+
|
28
|
+
def test_no_end_transition
|
29
|
+
tz = TZInfo::Timezone.get('America/Cayman').ical_timezone DateTime.now
|
30
|
+
assert_equal <<-EXPECTED.gsub("\n", "\r\n"), tz.to_ical
|
31
|
+
BEGIN:VTIMEZONE
|
32
|
+
TZID:America/Cayman
|
33
|
+
BEGIN:STANDARD
|
34
|
+
DTSTART:19120201T000712
|
35
|
+
TZNAME:EST
|
36
|
+
TZOFFSETFROM:-0652
|
37
|
+
TZOFFSETTO:-0500
|
38
|
+
END:STANDARD
|
39
|
+
END:VTIMEZONE
|
40
|
+
EXPECTED
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_no_transition
|
44
|
+
tz = TZInfo::Timezone.get('UTC').ical_timezone DateTime.now
|
45
|
+
assert_equal <<-EXPECTED.gsub("\n", "\r\n"), tz.to_ical
|
46
|
+
BEGIN:VTIMEZONE
|
47
|
+
TZID:UTC
|
48
|
+
BEGIN:STANDARD
|
49
|
+
DTSTART:19700101T000000
|
50
|
+
TZNAME:UTC
|
51
|
+
TZOFFSETFROM:+0000
|
52
|
+
TZOFFSETTO:+0000
|
53
|
+
END:STANDARD
|
54
|
+
END:VTIMEZONE
|
55
|
+
EXPECTED
|
56
|
+
end
|
27
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: icalendar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Ahearn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyforge
|