icalendar 2.11.1 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/icalendar/offset/windows_to_iana.rb +144 -0
- data/lib/icalendar/offset.rb +6 -4
- data/lib/icalendar/parser.rb +6 -1
- data/lib/icalendar/version.rb +1 -1
- data/spec/fixtures/single_event_bad_location.ics +23 -0
- data/spec/parser_spec.rb +10 -0
- data/spec/values/date_time_spec.rb +22 -7
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9aaf6132f4baffabc0b6a45fb4a1a5049e58b4ca264eddaac67648575e6702c6
|
4
|
+
data.tar.gz: ac0ee8ac873a3a9d97ad8914aa6f2bf3edb545f1d58d0d152988850cce9fca07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a330a0e6568705cc448eef9090d54c72b59fc78fec537ca715523689b5954875c76e0a16957ec344bce71fcb4b8f1f9e62af7c57591eef49d4682acee431a3e1
|
7
|
+
data.tar.gz: 2f49d14ad8759d16324a04f1472eee65e05fc5a1a9167ab5a93da5e2cdddab11cd8a61bad95718533747f10f7f8bf4b7a664e67e8b743d0cf490a1657f55dcdd
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
## Unreleased
|
2
2
|
|
3
|
+
## 2.12.0 - 2025-09-26
|
4
|
+
- Support timezone lookup by Windows names - Ronak Gothi
|
5
|
+
|
6
|
+
## 2.11.2 - 2025-06-21
|
7
|
+
- Deal with more bad value parameter values by falling back to the property default type
|
8
|
+
|
3
9
|
## 2.11.1 - 2025-06-06
|
4
10
|
- Gracefully deal with malformed ics files that use spaces in the value parameter instead of hyphens
|
5
11
|
|
@@ -0,0 +1,144 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This module contains mappings from Windows timezone identifiers to Olson timezone identifiers.
|
4
|
+
#
|
5
|
+
# The data is taken from the unicode consortium [0], the proposal and rationale
|
6
|
+
# for this mapping is also available at the unicode consortium [1].
|
7
|
+
#
|
8
|
+
# [0] https://www.unicode.org/cldr/cldr-aux/charts/29/supplemental/zone_tzid.html
|
9
|
+
# [1] https://cldr.unicode.org/development/development-process/design-proposals/extended-windows-olson-zid-mapping
|
10
|
+
|
11
|
+
module Icalendar
|
12
|
+
class Offset
|
13
|
+
class WindowsToIana < Offset
|
14
|
+
WINDOWS_TO_IANA = {
|
15
|
+
'AUS Central Standard Time' => 'Australia/Darwin',
|
16
|
+
'AUS Eastern Standard Time' => 'Australia/Sydney',
|
17
|
+
'Afghanistan Standard Time' => 'Asia/Kabul',
|
18
|
+
'Alaskan Standard Time' => 'America/Anchorage',
|
19
|
+
'Arab Standard Time' => 'Asia/Riyadh',
|
20
|
+
'Arabian Standard Time' => 'Asia/Dubai',
|
21
|
+
'Arabic Standard Time' => 'Asia/Baghdad',
|
22
|
+
'Argentina Standard Time' => 'America/Argentina/Buenos_Aires',
|
23
|
+
'Atlantic Standard Time' => 'America/Halifax',
|
24
|
+
'Azerbaijan Standard Time' => 'Asia/Baku',
|
25
|
+
'Azores Standard Time' => 'Atlantic/Azores',
|
26
|
+
'Bahia Standard Time' => 'America/Bahia',
|
27
|
+
'Bangladesh Standard Time' => 'Asia/Dhaka',
|
28
|
+
'Belarus Standard Time' => 'Europe/Minsk',
|
29
|
+
'Canada Central Standard Time' => 'America/Regina',
|
30
|
+
'Cape Verde Standard Time' => 'Atlantic/Cape_Verde',
|
31
|
+
'Caucasus Standard Time' => 'Asia/Yerevan',
|
32
|
+
'Cen. Australia Standard Time' => 'Australia/Adelaide',
|
33
|
+
'Central America Standard Time' => 'America/Guatemala',
|
34
|
+
'Central Asia Standard Time' => 'Asia/Almaty',
|
35
|
+
'Central Brazilian Standard Time' => 'America/Cuiaba',
|
36
|
+
'Central Europe Standard Time' => 'Europe/Budapest',
|
37
|
+
'Central European Standard Time' => 'Europe/Warsaw',
|
38
|
+
'Central Pacific Standard Time' => 'Pacific/Guadalcanal',
|
39
|
+
'Central Standard Time' => 'America/Chicago',
|
40
|
+
'Central Standard Time (Mexico)' => 'America/Mexico_City',
|
41
|
+
'China Standard Time' => 'Asia/Shanghai',
|
42
|
+
'Dateline Standard Time' => 'Etc/GMT+12',
|
43
|
+
'E. Africa Standard Time' => 'Africa/Nairobi',
|
44
|
+
'E. Australia Standard Time' => 'Australia/Brisbane',
|
45
|
+
'E. Europe Standard Time' => 'Europe/Chisinau',
|
46
|
+
'E. South America Standard Time' => 'America/Sao_Paulo',
|
47
|
+
'Eastern Standard Time' => 'America/New_York',
|
48
|
+
'Eastern Standard Time (Mexico)' => 'America/Cancun',
|
49
|
+
'Egypt Standard Time' => 'Africa/Cairo',
|
50
|
+
'Ekaterinburg Standard Time' => 'Asia/Yekaterinburg',
|
51
|
+
'FLE Standard Time' => 'Europe/Kyiv',
|
52
|
+
'Fiji Standard Time' => 'Pacific/Fiji',
|
53
|
+
'GMT Standard Time' => 'Europe/London',
|
54
|
+
'GTB Standard Time' => 'Europe/Bucharest',
|
55
|
+
'Georgian Standard Time' => 'Asia/Tbilisi',
|
56
|
+
'Greenland Standard Time' => 'America/Nuuk',
|
57
|
+
'Greenwich Standard Time' => 'Atlantic/Reykjavik',
|
58
|
+
'Hawaiian Standard Time' => 'Pacific/Honolulu',
|
59
|
+
'India Standard Time' => 'Asia/Kolkata',
|
60
|
+
'Iran Standard Time' => 'Asia/Tehran',
|
61
|
+
'Israel Standard Time' => 'Asia/Jerusalem',
|
62
|
+
'Jordan Standard Time' => 'Asia/Amman',
|
63
|
+
'Kaliningrad Standard Time' => 'Europe/Kaliningrad',
|
64
|
+
'Korea Standard Time' => 'Asia/Seoul',
|
65
|
+
'Libya Standard Time' => 'Africa/Tripoli',
|
66
|
+
'Line Islands Standard Time' => 'Pacific/Kiritimati',
|
67
|
+
'Magadan Standard Time' => 'Asia/Magadan',
|
68
|
+
'Mauritius Standard Time' => 'Indian/Mauritius',
|
69
|
+
'Middle East Standard Time' => 'Asia/Beirut',
|
70
|
+
'Montevideo Standard Time' => 'America/Montevideo',
|
71
|
+
'Morocco Standard Time' => 'Africa/Casablanca',
|
72
|
+
'Mountain Standard Time' => 'America/Denver',
|
73
|
+
'Mountain Standard Time (Mexico)' => 'America/Chihuahua',
|
74
|
+
'Myanmar Standard Time' => 'Asia/Yangon',
|
75
|
+
'N. Central Asia Standard Time' => 'Asia/Novosibirsk',
|
76
|
+
'Namibia Standard Time' => 'Africa/Windhoek',
|
77
|
+
'Nepal Standard Time' => 'Asia/Kathmandu',
|
78
|
+
'New Zealand Standard Time' => 'Pacific/Auckland',
|
79
|
+
'Newfoundland Standard Time' => 'America/St_Johns',
|
80
|
+
'North Asia East Standard Time' => 'Asia/Irkutsk',
|
81
|
+
'North Asia Standard Time' => 'Asia/Krasnoyarsk',
|
82
|
+
'North Korea Standard Time' => 'Asia/Pyongyang',
|
83
|
+
'Pacific SA Standard Time' => 'America/Santiago',
|
84
|
+
'Pacific Standard Time' => 'America/Los_Angeles',
|
85
|
+
'Pakistan Standard Time' => 'Asia/Karachi',
|
86
|
+
'Paraguay Standard Time' => 'America/Asuncion',
|
87
|
+
'Romance Standard Time' => 'Europe/Paris',
|
88
|
+
'Russia Time Zone 10' => 'Asia/Srednekolymsk',
|
89
|
+
'Russia Time Zone 11' => 'Asia/Kamchatka',
|
90
|
+
'Russia Time Zone 3' => 'Europe/Samara',
|
91
|
+
'Russian Standard Time' => 'Europe/Moscow',
|
92
|
+
'SA Eastern Standard Time' => 'America/Cayenne',
|
93
|
+
'SA Pacific Standard Time' => 'America/Bogota',
|
94
|
+
'SA Western Standard Time' => 'America/La_Paz',
|
95
|
+
'SE Asia Standard Time' => 'Asia/Bangkok',
|
96
|
+
'Samoa Standard Time' => 'Pacific/Apia',
|
97
|
+
'Singapore Standard Time' => 'Asia/Singapore',
|
98
|
+
'South Africa Standard Time' => 'Africa/Johannesburg',
|
99
|
+
'Sri Lanka Standard Time' => 'Asia/Colombo',
|
100
|
+
'Syria Standard Time' => 'Asia/Damascus',
|
101
|
+
'Taipei Standard Time' => 'Asia/Taipei',
|
102
|
+
'Tasmania Standard Time' => 'Australia/Hobart',
|
103
|
+
'Tokyo Standard Time' => 'Asia/Tokyo',
|
104
|
+
'Tonga Standard Time' => 'Pacific/Tongatapu',
|
105
|
+
'Turkey Standard Time' => 'Europe/Istanbul',
|
106
|
+
'US Eastern Standard Time' => 'America/Indiana/Indianapolis',
|
107
|
+
'US Mountain Standard Time' => 'America/Phoenix',
|
108
|
+
'UTC' => 'Etc/GMT',
|
109
|
+
'UTC+12' => 'Etc/GMT-12',
|
110
|
+
'UTC-02' => 'Etc/GMT+2',
|
111
|
+
'UTC-11' => 'Etc/GMT+11',
|
112
|
+
'Ulaanbaatar Standard Time' => 'Asia/Ulaanbaatar',
|
113
|
+
'Venezuela Standard Time' => 'America/Caracas',
|
114
|
+
'Vladivostok Standard Time' => 'Asia/Vladivostok',
|
115
|
+
'W. Australia Standard Time' => 'Australia/Perth',
|
116
|
+
'W. Central Africa Standard Time' => 'Africa/Lagos',
|
117
|
+
'W. Europe Standard Time' => 'Europe/Berlin',
|
118
|
+
'West Asia Standard Time' => 'Asia/Tashkent',
|
119
|
+
'West Pacific Standard Time' => 'Pacific/Port_Moresby',
|
120
|
+
'Yakutsk Standard Time' => 'Asia/Yakutsk'
|
121
|
+
}.freeze
|
122
|
+
|
123
|
+
def valid?
|
124
|
+
support_classes_defined? && tz
|
125
|
+
end
|
126
|
+
|
127
|
+
def normalized_value
|
128
|
+
Icalendar.logger.debug("Plan a - parsing #{value}/#{tzid} as ActiveSupport::TimeWithZone")
|
129
|
+
# plan a - use ActiveSupport::TimeWithZone
|
130
|
+
Icalendar::Values::Helpers::ActiveSupportTimeWithZoneAdapter.new(nil, tz, value)
|
131
|
+
end
|
132
|
+
|
133
|
+
def normalized_tzid
|
134
|
+
[WINDOWS_TO_IANA[tzid]].compact
|
135
|
+
end
|
136
|
+
|
137
|
+
private
|
138
|
+
|
139
|
+
def tz
|
140
|
+
@tz ||= ActiveSupport::TimeZone[normalized_tzid.first || '']
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
data/lib/icalendar/offset.rb
CHANGED
@@ -10,6 +10,7 @@ module Icalendar
|
|
10
10
|
[
|
11
11
|
Icalendar::Offset::ActiveSupportExact,
|
12
12
|
Icalendar::Offset::TimeZoneStore,
|
13
|
+
Icalendar::Offset::WindowsToIana,
|
13
14
|
Icalendar::Offset::ActiveSupportPartial,
|
14
15
|
Icalendar::Offset::Null
|
15
16
|
].lazy.map { |klass| klass.new(tzid, value, timezone_store) }.detect(&:valid?)
|
@@ -36,7 +37,8 @@ module Icalendar
|
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
39
|
-
require_relative
|
40
|
-
require_relative
|
41
|
-
require_relative
|
42
|
-
require_relative
|
40
|
+
require_relative 'offset/active_support_exact'
|
41
|
+
require_relative 'offset/active_support_partial'
|
42
|
+
require_relative 'offset/null'
|
43
|
+
require_relative 'offset/time_zone_store'
|
44
|
+
require_relative 'offset/windows_to_iana'
|
data/lib/icalendar/parser.rb
CHANGED
@@ -113,7 +113,12 @@ module Icalendar
|
|
113
113
|
klass_name = fields[:params].delete('value').first
|
114
114
|
unless klass_name.upcase == klass.value_type
|
115
115
|
klass_name = "Icalendar::Values::#{klass_name.downcase.gsub(GET_WRAPPER_CLASS_GSUB_REGEX) { |m| m[-1].upcase }}"
|
116
|
-
|
116
|
+
begin
|
117
|
+
klass = Object.const_get klass_name if Object.const_defined?(klass_name)
|
118
|
+
rescue NameError => e
|
119
|
+
Icalendar.logger.error "NameError trying to find value type for #{component.name} | #{fields[:name]}: #{e.message}"
|
120
|
+
raise e if strict?
|
121
|
+
end
|
117
122
|
end
|
118
123
|
end
|
119
124
|
klass
|
data/lib/icalendar/version.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
BEGIN:VCALENDAR
|
2
|
+
VERSION:2.0
|
3
|
+
PRODID:bsprodidfortestabc123
|
4
|
+
CALSCALE:GREGORIAN
|
5
|
+
BEGIN:VEVENT
|
6
|
+
DTSTAMP:20050118T211523Z
|
7
|
+
UID:bsuidfortestabc123
|
8
|
+
DTSTART;TZID=US-Mountain:20050120T170000
|
9
|
+
DTEND;TZID=US-Mountain:20050120T184500
|
10
|
+
CLASS:PRIVATE
|
11
|
+
GEO:37.386013;-122.0829322
|
12
|
+
ORGANIZER;CN="Joe Bob: Magician":mailto:joebob@random.net
|
13
|
+
LOCATION;VALUE=1000 MAIN ST EXAMPLE, STATE 12345:1000 Main St Example\, State 12345
|
14
|
+
PRIORITY:2
|
15
|
+
SUMMARY:This is a really long summary to test the method of unfolding lines
|
16
|
+
\, so I'm just going to make it a whole bunch of lines. With a twist: a "
|
17
|
+
ö" takes up multiple bytes\, and should be wrapped to the next line.
|
18
|
+
ATTACH:http://bush.sucks.org/impeach/him.rhtml
|
19
|
+
ATTACH:http://corporations-dominate.existence.net/why.rhtml
|
20
|
+
RDATE;TZID=US-Mountain:20050121T170000,20050122T170000
|
21
|
+
X-TEST-COMPONENT;QTEST="Hello, World":Shouldn't double double quotes
|
22
|
+
END:VEVENT
|
23
|
+
END:VCALENDAR
|
data/spec/parser_spec.rb
CHANGED
@@ -116,4 +116,14 @@ describe Icalendar::Parser do
|
|
116
116
|
expect(event.dtstart).to be_kind_of Icalendar::Values::Date
|
117
117
|
end
|
118
118
|
end
|
119
|
+
|
120
|
+
describe 'completely bad location value' do
|
121
|
+
let(:fn) { 'single_event_bad_location.ics' }
|
122
|
+
|
123
|
+
it 'falls back to string type for location' do
|
124
|
+
event = subject.parse.first.events.first
|
125
|
+
expect(event.location).to be_kind_of Icalendar::Values::Text
|
126
|
+
expect(event.location.value).to eq "1000 Main St Example, State 12345"
|
127
|
+
end
|
128
|
+
end
|
119
129
|
end
|
@@ -17,7 +17,7 @@ describe Icalendar::Values::DateTime do
|
|
17
17
|
expect(subject.value_ical).to eq value
|
18
18
|
end
|
19
19
|
|
20
|
-
context '
|
20
|
+
context 'tzid in IANA format' do
|
21
21
|
let(:value) { '20140209T160652' }
|
22
22
|
let(:params) { {'tzid' => 'America/Denver'} }
|
23
23
|
|
@@ -28,14 +28,15 @@ describe Icalendar::Values::DateTime do
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
context '
|
31
|
+
context 'tzid with partial match' do
|
32
32
|
let(:value) { '20230901T230404' }
|
33
|
-
let(:params) { {'tzid' => 'Singapore
|
33
|
+
let(:params) { { 'tzid' => 'Singapore Time' } }
|
34
34
|
|
35
35
|
it 'parses the value as local time' do
|
36
36
|
expect(subject.value.hour).to eq 23
|
37
|
-
expect(subject.value.utc_offset).to eq
|
37
|
+
expect(subject.value.utc_offset).to eq 28_800
|
38
38
|
expect(subject.value.utc.hour).to eq 15
|
39
|
+
expect(subject.value.utc.minute).to eq 04
|
39
40
|
end
|
40
41
|
|
41
42
|
it 'updates the tzid' do
|
@@ -43,8 +44,24 @@ describe Icalendar::Values::DateTime do
|
|
43
44
|
expect(subject.ical_params['tzid']).to eq ['Asia/Singapore']
|
44
45
|
end
|
45
46
|
end
|
46
|
-
end
|
47
47
|
|
48
|
+
context 'tzid in windows format' do
|
49
|
+
let(:value) { '20230901T230404' }
|
50
|
+
let(:params) { { 'tzid' => 'India Standard Time' } }
|
51
|
+
|
52
|
+
it 'parses the value as local time' do
|
53
|
+
expect(subject.value.hour).to eq 23
|
54
|
+
expect(subject.value.utc_offset).to eq 19_800
|
55
|
+
expect(subject.value.utc.hour).to eq 17
|
56
|
+
expect(subject.value.utc.minute).to eq 34
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'updates the tzid' do
|
60
|
+
# use an array because that's how output from the parser will end up
|
61
|
+
expect(subject.ical_params['tzid']).to eq ['Asia/Kolkata']
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
48
65
|
else
|
49
66
|
|
50
67
|
context 'without ActiveSupport' do
|
@@ -63,10 +80,8 @@ describe Icalendar::Values::DateTime do
|
|
63
80
|
end
|
64
81
|
end
|
65
82
|
end
|
66
|
-
|
67
83
|
end
|
68
84
|
|
69
|
-
|
70
85
|
context 'common tests' do
|
71
86
|
it 'does not add any tzid parameter to output' do
|
72
87
|
expect(subject.to_ical described_class).to eq ":#{value}"
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: icalendar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Ahearn
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: base64
|
@@ -228,6 +227,7 @@ files:
|
|
228
227
|
- lib/icalendar/offset/active_support_partial.rb
|
229
228
|
- lib/icalendar/offset/null.rb
|
230
229
|
- lib/icalendar/offset/time_zone_store.rb
|
230
|
+
- lib/icalendar/offset/windows_to_iana.rb
|
231
231
|
- lib/icalendar/parser.rb
|
232
232
|
- lib/icalendar/timezone.rb
|
233
233
|
- lib/icalendar/timezone_store.rb
|
@@ -267,6 +267,7 @@ files:
|
|
267
267
|
- spec/fixtures/single_event.ics
|
268
268
|
- spec/fixtures/single_event_bad_dtstart.ics
|
269
269
|
- spec/fixtures/single_event_bad_line.ics
|
270
|
+
- spec/fixtures/single_event_bad_location.ics
|
270
271
|
- spec/fixtures/single_event_bad_organizer.ics
|
271
272
|
- spec/fixtures/single_event_organizer_parsed.ics
|
272
273
|
- spec/fixtures/timezone.ics
|
@@ -316,8 +317,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
316
317
|
- !ruby/object:Gem::Version
|
317
318
|
version: '0'
|
318
319
|
requirements: []
|
319
|
-
rubygems_version: 3.
|
320
|
-
signing_key:
|
320
|
+
rubygems_version: 3.6.9
|
321
321
|
specification_version: 4
|
322
322
|
summary: A ruby implementation of the iCalendar specification (RFC-5545).
|
323
323
|
test_files:
|
@@ -335,6 +335,7 @@ test_files:
|
|
335
335
|
- spec/fixtures/single_event.ics
|
336
336
|
- spec/fixtures/single_event_bad_dtstart.ics
|
337
337
|
- spec/fixtures/single_event_bad_line.ics
|
338
|
+
- spec/fixtures/single_event_bad_location.ics
|
338
339
|
- spec/fixtures/single_event_bad_organizer.ics
|
339
340
|
- spec/fixtures/single_event_organizer_parsed.ics
|
340
341
|
- spec/fixtures/timezone.ics
|