greenwich 2.0.3 → 2.0.4
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.
- data/lib/greenwich/conversion.rb +1 -0
- data/lib/greenwich/version.rb +1 -1
- data/spec/conversion_spec.rb +12 -2
- metadata +2 -3
data/lib/greenwich/conversion.rb
CHANGED
@@ -30,6 +30,7 @@ module Greenwich
|
|
30
30
|
time_zone = Greenwich::Utilities.get_time_zone(self, time_zone_field)
|
31
31
|
time = Greenwich::Utilities.coerce_to_time_without_zone(value)
|
32
32
|
time = ActiveSupport::TimeWithZone.new(nil, time_zone, time) if time && time_zone
|
33
|
+
time = ActiveSupport::TimeWithZone.new(nil, ActiveSupport::TimeZone.new('UTC'), time) if time && !time_zone
|
33
34
|
|
34
35
|
greenwich_time_fields_converted["#{time_field}_utc"] = true unless time_zone.nil?
|
35
36
|
|
data/lib/greenwich/version.rb
CHANGED
data/spec/conversion_spec.rb
CHANGED
@@ -182,15 +182,25 @@ describe Greenwich::Conversion do
|
|
182
182
|
before { model.time_zone = nil }
|
183
183
|
|
184
184
|
context 'and the time field is set' do
|
185
|
-
before { model.started_at = Time.
|
185
|
+
before { model.started_at = Time.find_zone('Alaska').local(2012, 1, 2, 12, 59, 1) }
|
186
186
|
|
187
|
-
it 'the time field is
|
187
|
+
it 'the time field is adjusted' do
|
188
|
+
model.started_at.should eql Time.utc(2012, 1, 2, 12, 59, 1)
|
188
189
|
raw_time_field.should eql Time.utc(2012, 1, 2, 12, 59, 1)
|
189
190
|
end
|
190
191
|
|
191
192
|
it 'needs to be converted' do
|
192
193
|
model.send(:greenwich_time_field_needs_conversion?, 'started_at', 'time_zone').should be_true
|
193
194
|
end
|
195
|
+
|
196
|
+
context 'and then the time zone is set' do
|
197
|
+
before { model.time_zone = 'Hawaii' }
|
198
|
+
|
199
|
+
it 'reflects the local time zone' do
|
200
|
+
model.started_at.should eql Time.find_zone('Hawaii').local(2012, 1, 2, 12, 59, 1)
|
201
|
+
raw_time_field.should eql Time.utc(2012, 1, 2, 22, 59, 1)
|
202
|
+
end
|
203
|
+
end
|
194
204
|
end
|
195
205
|
|
196
206
|
context 'and the time field is not set' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: greenwich
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-12-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -236,4 +236,3 @@ test_files:
|
|
236
236
|
- spec/support/focused.rb
|
237
237
|
- spec/support/pending.rb
|
238
238
|
- spec/utilities_spec.rb
|
239
|
-
has_rdoc:
|