dtg 4.0.1 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +2 -0
- data/.gitignore +39 -0
- data/.inch.yml +6 -0
- data/.prettierignore +49 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/.travis.yml +20 -0
- data/CHANGELOG.md +0 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +0 -42
- data/Gemfile.lock +70 -0
- data/LICENSE +21 -0
- data/README.md +225 -0
- data/Rakefile +11 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/dtg.gemspec +46 -27
- data/dtg_zones.png +0 -0
- data/lib/dtg.rb +20 -7
- data/lib/dtg/active_support/time_with_zone_ext.rb +2 -2
- data/lib/dtg/date_time_ext.rb +3 -3
- data/lib/dtg/date_time_group.rb +54 -2
- data/lib/dtg/format.rb +59 -0
- data/lib/dtg/time_ext.rb +2 -2
- data/lib/dtg/version.rb +1 -1
- data/lib/dtg/zones.rb +2 -2
- data/spec/dtg/active_support/time_with_zone_ext_spec.rb +176 -0
- data/spec/dtg/date_time_ext_spec.rb +175 -0
- data/spec/dtg/date_time_group_spec.rb +73 -0
- data/spec/dtg/format_spec.rb +99 -0
- data/spec/dtg/time_ext_spec.rb +175 -0
- data/spec/{lib/dtg → dtg}/zones_spec.rb +29 -31
- data/spec/dtg_spec.rb +13 -0
- data/spec/spec_helper.rb +7 -94
- metadata +109 -18
- data/spec/lib/dtg/active_support/time_with_zone_ext_spec.rb +0 -169
- data/spec/lib/dtg/date_time_ext_spec.rb +0 -168
- data/spec/lib/dtg/date_time_group_spec.rb +0 -35
- data/spec/lib/dtg/time_ext_spec.rb +0 -168
- data/spec/lib/dtg_spec.rb +0 -9
@@ -0,0 +1,175 @@
|
|
1
|
+
RSpec.describe DateTime do
|
2
|
+
# Set Time Zone before tests
|
3
|
+
before { Time.zone = 'UTC' }
|
4
|
+
|
5
|
+
let(:time) { described_class.now { include DateTimeGroup } }
|
6
|
+
|
7
|
+
describe '#to_dtg' do
|
8
|
+
context 'when zone is a symbol' do
|
9
|
+
context 'when symbol is lowercase' do
|
10
|
+
it 'converts and formats as dtg' do
|
11
|
+
(:a..:z).to_set.delete(:j).each do |zone|
|
12
|
+
expect(time.to_dtg(zone)).to eq(
|
13
|
+
time.in_time_zone(Zones::UTC_ZONES[zone]).strftime(
|
14
|
+
"%d%H%M#{zone.upcase.to_s} %b %y"
|
15
|
+
)
|
16
|
+
)
|
17
|
+
end
|
18
|
+
# :j is separate because there is no local timezone identifier,
|
19
|
+
# it just gets returned and formatted
|
20
|
+
expect(time.to_dtg(:j)).to eq(time.format(:j))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when symbol is uppercase' do
|
25
|
+
it 'converts and formats as dtg' do
|
26
|
+
(:A..:Z).to_set.delete(:J).each do |zone|
|
27
|
+
expect(time.to_dtg(zone)).to eq(
|
28
|
+
time.in_time_zone(Zones::UTC_ZONES[zone.downcase]).strftime(
|
29
|
+
"%d%H%M#{zone.to_s} %b %y"
|
30
|
+
)
|
31
|
+
)
|
32
|
+
end
|
33
|
+
# :J is separate because there is no local timezone identifier,
|
34
|
+
# it just gets returned and formatted
|
35
|
+
expect(time.to_dtg(:J)).to eq(time.format(:j))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'when zone is a single character string' do
|
41
|
+
context 'when string is lowercase' do
|
42
|
+
it 'converts and formats as dtg' do
|
43
|
+
('a'..'z').to_set.delete('j').each do |zone|
|
44
|
+
expect(time.to_dtg(zone)).to eq(
|
45
|
+
time.in_time_zone(Zones::UTC_ZONES[zone.to_sym]).strftime(
|
46
|
+
"%d%H%M#{zone.upcase} %b %y"
|
47
|
+
)
|
48
|
+
)
|
49
|
+
end
|
50
|
+
# 'j' is separate because there is no local timezone identifier
|
51
|
+
# it just gets returned and formatted
|
52
|
+
expect(time.to_dtg('j')).to eq(time.format(:j))
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'when string is uppercase' do
|
57
|
+
it 'converts and formats as dtg' do
|
58
|
+
('A'..'Z').to_set.delete('J').each do |zone|
|
59
|
+
expect(time.to_dtg(zone)).to eq(
|
60
|
+
time.in_time_zone(Zones::UTC_ZONES[zone.downcase.to_sym])
|
61
|
+
.strftime("%d%H%M#{zone} %b %y")
|
62
|
+
)
|
63
|
+
end
|
64
|
+
# 'J' is separate because there is no local timezone identifier,
|
65
|
+
# it just gets returned and formatted
|
66
|
+
expect(time.to_dtg('J')).to eq(time.format(:j))
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '#format' do
|
73
|
+
context 'when zone is a symbol' do
|
74
|
+
context 'when symbol is lowercase' do
|
75
|
+
it 'formats to dtg standard' do
|
76
|
+
(:a..:z).each do |zone|
|
77
|
+
expect(time.format(zone)).to eq(
|
78
|
+
time.strftime("%d%H%M#{zone.upcase.to_s} %b %y")
|
79
|
+
)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'when symbol is uppercase' do
|
85
|
+
it 'formats to dtg standard' do
|
86
|
+
(:A..:Z).each do |zone|
|
87
|
+
expect(time.format(zone)).to eq(
|
88
|
+
time.strftime("%d%H%M#{zone.to_s} %b %y")
|
89
|
+
)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context 'when zone is a single character string' do
|
96
|
+
context 'when string is lowercase' do
|
97
|
+
it 'formats to dtg standard' do
|
98
|
+
('a'..'z').each do |zone|
|
99
|
+
expect(time.format(zone)).to eq(
|
100
|
+
time.strftime("%d%H%M#{zone.upcase} %b %y")
|
101
|
+
)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context 'when string is uppercase' do
|
107
|
+
it 'formats to dtg standard' do
|
108
|
+
('A'..'Z').each do |zone|
|
109
|
+
expect(time.format(zone)).to eq(
|
110
|
+
time.strftime("%d%H%M#{zone} %b %y")
|
111
|
+
)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
describe '#convert' do
|
119
|
+
context 'when zone is a symbol' do
|
120
|
+
context 'when symbol is lowercase' do
|
121
|
+
it 'returns converted time to new zone' do
|
122
|
+
(:a..:z).to_set.delete(:j).each do |zone|
|
123
|
+
expect(time.convert(zone)).to eq(
|
124
|
+
time.in_time_zone(Zones::UTC_ZONES[zone])
|
125
|
+
)
|
126
|
+
end
|
127
|
+
# :j is separate because there is no local timezone identifier,
|
128
|
+
# it just gets returned and formatted
|
129
|
+
expect(time.convert(:j)).to eq(time)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
context 'when symbol is uppercase' do
|
134
|
+
it 'returns converted time to new zone' do
|
135
|
+
(:A..:Z).to_set.delete(:J).each do |zone|
|
136
|
+
expect(time.convert(zone)).to eq(
|
137
|
+
time.in_time_zone(Zones::UTC_ZONES[zone.downcase])
|
138
|
+
)
|
139
|
+
end
|
140
|
+
# :J is separate because there is no local timezone identifier,
|
141
|
+
# it just gets returned and formatted
|
142
|
+
expect(time.convert(:J)).to eq(time)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
context 'when zone is a single character string' do
|
148
|
+
context 'when string is lowercase' do
|
149
|
+
it 'returns converted time to new zone' do
|
150
|
+
('a'..'z').to_set.delete('j').each do |zone|
|
151
|
+
expect(time.convert(zone)).to eq(
|
152
|
+
time.in_time_zone(Zones::UTC_ZONES[zone.to_sym])
|
153
|
+
)
|
154
|
+
end
|
155
|
+
# 'j' is separate because there is no local timezone identifier,
|
156
|
+
# it just gets returned and formatted
|
157
|
+
expect(time.convert('j')).to eq(time)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
context 'when string is uppercase' do
|
162
|
+
it 'returns converted time to new zone' do
|
163
|
+
('A'..'Z').to_set.delete('J').each do |zone|
|
164
|
+
expect(time.convert(zone)).to eq(
|
165
|
+
time.in_time_zone(Zones::UTC_ZONES[zone.downcase.to_sym])
|
166
|
+
)
|
167
|
+
end
|
168
|
+
# 'J' is separate because there is no local timezone identifier,
|
169
|
+
# it just gets returned and formatted
|
170
|
+
expect(time.convert('J')).to eq(time)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
RSpec.describe DateTimeGroup do
|
2
|
+
# Set Time Zone before tests: ActiveSupport::TimeWithZone needs this or will nil:nilObject (e.g. Time.zone.now)
|
3
|
+
before do
|
4
|
+
# UTC is a fair zone right?
|
5
|
+
Time.zone = 'UTC'
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '#dtg' do
|
9
|
+
context 'when the object is a DateTime' do
|
10
|
+
let(:dummy) { DateTime.new { include described_class } }
|
11
|
+
|
12
|
+
it 'returns datetime in a string' do
|
13
|
+
expect(dummy.dtg).to eq(
|
14
|
+
"DTG gem is natively integrated with this class: #{dummy.class}"
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'when the object is a Time' do
|
20
|
+
let(:dummy) { Time.new { include described_class } }
|
21
|
+
|
22
|
+
it 'returns time in a string' do
|
23
|
+
expect(dummy.dtg).to eq(
|
24
|
+
"DTG gem is natively integrated with this class: #{dummy.class}"
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'when the object is an ActiveSupport::TimeWithZone' do
|
30
|
+
# ActiveSupport::TimeWithZone.new is not allowed to instantiate empty class
|
31
|
+
let(:dummy) { Time.zone.now { include described_class } }
|
32
|
+
|
33
|
+
it 'returns the ActiveSupport::TimeWithZone in a string' do
|
34
|
+
expect(dummy.dtg).to eq(
|
35
|
+
"DTG gem is natively integrated with this class: #{dummy.class}"
|
36
|
+
)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '.parse' do
|
42
|
+
it 'parses a dtg into its parts' do
|
43
|
+
time = Time.now.convert(:z)
|
44
|
+
dtg = time.to_dtg(:z)
|
45
|
+
parsed = described_class.parse(dtg)
|
46
|
+
expect(parsed[:day]).to eq(time.strftime('%d').to_s)
|
47
|
+
expect(parsed[:hour]).to eq(time.strftime('%H').to_s)
|
48
|
+
expect(parsed[:minute]).to eq(time.strftime('%M').to_s)
|
49
|
+
expect(parsed[:zone]).to eq('Z')
|
50
|
+
expect(parsed[:month]).to eq(time.strftime('%b'))
|
51
|
+
expect(parsed[:year]).to eq(time.strftime('%y'))
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '.from_dtg' do
|
56
|
+
it 'converts from a dtg into the proper time' do
|
57
|
+
time = Time.now.convert(:z)
|
58
|
+
dtg = time.to_dtg(:z)
|
59
|
+
# anything less than minutes is lost in a DTG
|
60
|
+
time = time.change(usec: 0)
|
61
|
+
time = time.change(sec: 0)
|
62
|
+
expect(described_class.from_dtg(dtg)).to eq(time)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '.convert' do
|
67
|
+
it 'converts a dtg into a different zoned dtg' do
|
68
|
+
time = Time.now.convert(:z)
|
69
|
+
dtg = time.to_dtg(:z)
|
70
|
+
expect(described_class.convert(dtg, :w)).to eq(time.to_dtg(:w))
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
RSpec.describe Format do
|
2
|
+
describe 'FORMAT' do
|
3
|
+
it 'shows a complete DTG size' do
|
4
|
+
expect(Format::FORMAT[:size]).to eq(14)
|
5
|
+
end
|
6
|
+
|
7
|
+
it 'shows the day field size' do
|
8
|
+
expect(Format::FORMAT[:size_day]).to eq(2)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'shows the hour field size' do
|
12
|
+
expect(Format::FORMAT[:size_hour]).to eq(2)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'shows the zone field size' do
|
16
|
+
expect(Format::FORMAT[:size_zone]).to eq(1)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'shows the month field size' do
|
20
|
+
expect(Format::FORMAT[:size_month]).to eq(3)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'shows the year field size' do
|
24
|
+
expect(Format::FORMAT[:size_year]).to eq(2)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'shows the day field start position' do
|
28
|
+
expect(Format::FORMAT[:day_start]).to eq(0)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'shows the day field end position' do
|
32
|
+
expect(Format::FORMAT[:day_end]).to eq(1)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'shows the day field position range' do
|
36
|
+
expect(Format::FORMAT[:day_range]).to eq(0..1)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'shows the hour field start position' do
|
40
|
+
expect(Format::FORMAT[:hour_start]).to eq(2)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'shows the hour field end position' do
|
44
|
+
expect(Format::FORMAT[:hour_end]).to eq(3)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'shows the hour field position range' do
|
48
|
+
expect(Format::FORMAT[:hour_range]).to eq(2..3)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'shows the minute field start position' do
|
52
|
+
expect(Format::FORMAT[:minute_start]).to eq(4)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'shows the minute field end position' do
|
56
|
+
expect(Format::FORMAT[:minute_end]).to eq(5)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'shows the minute field position range' do
|
60
|
+
expect(Format::FORMAT[:minute_range]).to eq(4..5)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'shows the zone field start position' do
|
64
|
+
expect(Format::FORMAT[:zone_start]).to eq(6)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'shows the zone field end position' do
|
68
|
+
expect(Format::FORMAT[:zone_end]).to eq(6)
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'shows the zone field position range' do
|
72
|
+
expect(Format::FORMAT[:zone_range]).to eq(6..6)
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'shows the month field start position' do
|
76
|
+
expect(Format::FORMAT[:month_start]).to eq(8)
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'shows the month field end position' do
|
80
|
+
expect(Format::FORMAT[:month_end]).to eq(10)
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'shows the month field position range' do
|
84
|
+
expect(Format::FORMAT[:month_range]).to eq(8..10)
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'shows the year field start position' do
|
88
|
+
expect(Format::FORMAT[:year_start]).to eq(12)
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'shows the year field end position' do
|
92
|
+
expect(Format::FORMAT[:year_end]).to eq(13)
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'shows the year field position range' do
|
96
|
+
expect(Format::FORMAT[:year_range]).to eq(12..13)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,175 @@
|
|
1
|
+
RSpec.describe Time do
|
2
|
+
# Set Time Zone before tests
|
3
|
+
before { described_class.zone = 'UTC' }
|
4
|
+
|
5
|
+
let(:time) { described_class.now { include DateTimeGroup } }
|
6
|
+
|
7
|
+
describe '#to_dtg' do
|
8
|
+
context 'when zone is a symbol' do
|
9
|
+
context 'when symbol is lowercase' do
|
10
|
+
it 'converts and formats as dtg' do
|
11
|
+
(:a..:z).to_set.delete(:j).each do |zone|
|
12
|
+
expect(time.to_dtg(zone)).to eq(
|
13
|
+
time.in_time_zone(Zones::UTC_ZONES[zone]).strftime(
|
14
|
+
"%d%H%M#{zone.upcase.to_s} %b %y"
|
15
|
+
)
|
16
|
+
)
|
17
|
+
end
|
18
|
+
# :j is separate because there is no local timezone identifier,
|
19
|
+
# it just gets returned and formatted
|
20
|
+
expect(time.to_dtg(:j)).to eq(time.format(:j))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when symbol is uppercase' do
|
25
|
+
it 'converts and formats as dtg' do
|
26
|
+
(:A..:Z).to_set.delete(:J).each do |zone|
|
27
|
+
expect(time.to_dtg(zone)).to eq(
|
28
|
+
time.in_time_zone(Zones::UTC_ZONES[zone.downcase]).strftime(
|
29
|
+
"%d%H%M#{zone.to_s} %b %y"
|
30
|
+
)
|
31
|
+
)
|
32
|
+
end
|
33
|
+
# :J is separate because there is no local timezone identifier,
|
34
|
+
# it just gets returned and formatted
|
35
|
+
expect(time.to_dtg(:J)).to eq(time.format(:j))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'when zone is a single character string' do
|
41
|
+
context 'when string is lowercase' do
|
42
|
+
it 'converts and formats as dtg' do
|
43
|
+
('a'..'z').to_set.delete('j').each do |zone|
|
44
|
+
expect(time.to_dtg(zone)).to eq(
|
45
|
+
time.in_time_zone(Zones::UTC_ZONES[zone.to_sym]).strftime(
|
46
|
+
"%d%H%M#{zone.upcase} %b %y"
|
47
|
+
)
|
48
|
+
)
|
49
|
+
end
|
50
|
+
# 'j' is separate because there is no local timezone identifier
|
51
|
+
# it just gets returned and formatted
|
52
|
+
expect(time.to_dtg('j')).to eq(time.format(:j))
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'when string is uppercase' do
|
57
|
+
it 'converts and formats as dtg' do
|
58
|
+
('A'..'Z').to_set.delete('J').each do |zone|
|
59
|
+
expect(time.to_dtg(zone)).to eq(
|
60
|
+
time.in_time_zone(Zones::UTC_ZONES[zone.downcase.to_sym])
|
61
|
+
.strftime("%d%H%M#{zone} %b %y")
|
62
|
+
)
|
63
|
+
end
|
64
|
+
# 'J' is separate because there is no local timezone identifier,
|
65
|
+
# it just gets returned and formatted
|
66
|
+
expect(time.to_dtg('J')).to eq(time.format(:j))
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '#format' do
|
73
|
+
context 'when zone is a symbol' do
|
74
|
+
context 'when symbol is lowercase' do
|
75
|
+
it 'formats to dtg standard' do
|
76
|
+
(:a..:z).each do |zone|
|
77
|
+
expect(time.format(zone)).to eq(
|
78
|
+
time.strftime("%d%H%M#{zone.upcase.to_s} %b %y")
|
79
|
+
)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'when symbol is uppercase' do
|
85
|
+
it 'formats to dtg standard' do
|
86
|
+
(:A..:Z).each do |zone|
|
87
|
+
expect(time.format(zone)).to eq(
|
88
|
+
time.strftime("%d%H%M#{zone.to_s} %b %y")
|
89
|
+
)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context 'when zone is a single character string' do
|
96
|
+
context 'when string is lowercase' do
|
97
|
+
it 'formats to dtg standard' do
|
98
|
+
('a'..'z').each do |zone|
|
99
|
+
expect(time.format(zone)).to eq(
|
100
|
+
time.strftime("%d%H%M#{zone.upcase} %b %y")
|
101
|
+
)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context 'when string is uppercase' do
|
107
|
+
it 'formats to dtg standard' do
|
108
|
+
('A'..'Z').each do |zone|
|
109
|
+
expect(time.format(zone)).to eq(
|
110
|
+
time.strftime("%d%H%M#{zone} %b %y")
|
111
|
+
)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
describe '#convert' do
|
119
|
+
context 'when zone is a symbol' do
|
120
|
+
context 'when symbol is lowercase' do
|
121
|
+
it 'returns converted time to new zone' do
|
122
|
+
(:a..:z).to_set.delete(:j).each do |zone|
|
123
|
+
expect(time.convert(zone)).to eq(
|
124
|
+
time.in_time_zone(Zones::UTC_ZONES[zone])
|
125
|
+
)
|
126
|
+
end
|
127
|
+
# :j is separate because there is no local timezone identifier,
|
128
|
+
# it just gets returned and formatted
|
129
|
+
expect(time.convert(:j)).to eq(time)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
context 'when symbol is uppercase' do
|
134
|
+
it 'returns converted time to new zone' do
|
135
|
+
(:A..:Z).to_set.delete(:J).each do |zone|
|
136
|
+
expect(time.convert(zone)).to eq(
|
137
|
+
time.in_time_zone(Zones::UTC_ZONES[zone.downcase])
|
138
|
+
)
|
139
|
+
end
|
140
|
+
# :J is separate because there is no local timezone identifier,
|
141
|
+
# it just gets returned and formatted
|
142
|
+
expect(time.convert(:J)).to eq(time)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
context 'when zone is a single character string' do
|
148
|
+
context 'when string is lowercase' do
|
149
|
+
it 'returns converted time to new zone' do
|
150
|
+
('a'..'z').to_set.delete('j').each do |zone|
|
151
|
+
expect(time.convert(zone)).to eq(
|
152
|
+
time.in_time_zone(Zones::UTC_ZONES[zone.to_sym])
|
153
|
+
)
|
154
|
+
end
|
155
|
+
# 'j' is separate because there is no local timezone identifier,
|
156
|
+
# it just gets returned and formatted
|
157
|
+
expect(time.convert('j')).to eq(time)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
context 'when string is uppercase' do
|
162
|
+
it 'returns converted time to new zone' do
|
163
|
+
('A'..'Z').to_set.delete('J').each do |zone|
|
164
|
+
expect(time.convert(zone)).to eq(
|
165
|
+
time.in_time_zone(Zones::UTC_ZONES[zone.downcase.to_sym])
|
166
|
+
)
|
167
|
+
end
|
168
|
+
# 'J' is separate because there is no local timezone identifier,
|
169
|
+
# it just gets returned and formatted
|
170
|
+
expect(time.convert('J')).to eq(time)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|