icalendar 2.11.2 → 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 +3 -0
- data/lib/icalendar/offset/windows_to_iana.rb +144 -0
- data/lib/icalendar/offset.rb +6 -4
- data/lib/icalendar/version.rb +1 -1
- data/spec/values/date_time_spec.rb +22 -7
- metadata +4 -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
@@ -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/version.rb
CHANGED
@@ -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
|
@@ -317,8 +317,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
317
317
|
- !ruby/object:Gem::Version
|
318
318
|
version: '0'
|
319
319
|
requirements: []
|
320
|
-
rubygems_version: 3.
|
321
|
-
signing_key:
|
320
|
+
rubygems_version: 3.6.9
|
322
321
|
specification_version: 4
|
323
322
|
summary: A ruby implementation of the iCalendar specification (RFC-5545).
|
324
323
|
test_files:
|