mongoid 0.8.1 → 0.8.2
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/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.2
|
@@ -3,9 +3,11 @@ module Mongoid #:nodoc:
|
|
3
3
|
module Time #:nodoc:
|
4
4
|
module Conversions #:nodoc:
|
5
5
|
def set(value)
|
6
|
+
return nil if value.blank?
|
6
7
|
::Time.parse(value.to_s).utc
|
7
8
|
end
|
8
9
|
def get(value)
|
10
|
+
return nil if value.blank?
|
9
11
|
::Time.zone ? ::Time.zone.parse(value.to_s).getlocal : value
|
10
12
|
end
|
11
13
|
end
|
data/mongoid.gemspec
CHANGED
@@ -29,12 +29,32 @@ describe Mongoid::Extensions::Time::Conversions do
|
|
29
29
|
|
30
30
|
end
|
31
31
|
|
32
|
+
context "when value is nil" do
|
33
|
+
|
34
|
+
it "returns nil" do
|
35
|
+
Time.set(nil).should be_nil
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
32
40
|
end
|
33
41
|
|
34
42
|
describe "#get" do
|
35
43
|
|
36
|
-
|
37
|
-
|
44
|
+
context "when time is provided" do
|
45
|
+
|
46
|
+
it "returns the local time" do
|
47
|
+
Time.get(@time.dup.utc).utc_offset.should == @time.utc_offset
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
context "when time is nil" do
|
53
|
+
|
54
|
+
it "returns nil" do
|
55
|
+
Time.get(nil).should be_nil
|
56
|
+
end
|
57
|
+
|
38
58
|
end
|
39
59
|
|
40
60
|
end
|