dm-zone-types 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
  module DataMapper
3
3
  module Zone
4
4
  module Types #:nodoc
5
- VERSION = '0.1.1'
5
+ VERSION = '0.1.2'
6
6
  end
7
7
  end
8
8
  end
@@ -6,13 +6,17 @@ module DataMapper
6
6
  class ZonedTime < Time
7
7
  include DataMapper::Zone::Types
8
8
 
9
+ def valid?(value)
10
+ value.kind_of?(::Time) || value.nil?
11
+ end
12
+
9
13
  def load(value)
10
14
  value.nil? ? nil : value.in_time_zone(::Time.zone)
11
15
  end
12
16
 
13
17
  def dump(value)
14
18
  return nil unless value
15
- value.in_time_zone(DataMapper::Zone::Types.storage_zone)
19
+ time_with_zone_to_primitive value.in_time_zone(DataMapper::Zone::Types.storage_zone)
16
20
  end
17
21
 
18
22
  def typecast(value)
@@ -31,6 +35,12 @@ module DataMapper
31
35
  nil
32
36
  end
33
37
  end
38
+
39
+ private
40
+ def time_with_zone_to_primitive(value)
41
+ value.to_datetime.to_time
42
+ end
34
43
  end
35
44
  end
36
45
  end
46
+
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-zone-types
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Daniel Neighman