date_validator 0.5.2 → 0.5.3

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.5.2
1
+ 0.5.3
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{date_validator}
8
- s.version = "0.5.2"
8
+ s.version = "0.5.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Oriol Gual", "Josep M\302\252 Bach", "Josep Jaume Rey"]
12
- s.date = %q{2010-06-18}
12
+ s.date = %q{2010-06-20}
13
13
  s.description = %q{A simple date validator for Rails 3. Currently supporting :after, :before, :after_or_equal_to and :before_or_equal_to options. Remarkable-friendly :)}
14
14
  s.email = %q{info@codegram.com}
15
15
  s.extra_rdoc_files = [
@@ -30,8 +30,17 @@ module ActiveModel
30
30
  options.slice(*CHECKS.keys).each do |option, option_value|
31
31
  option_value = option_value.call(record) if option_value.is_a?(Proc)
32
32
  option_value = record.send(option_value) if option_value.is_a?(Symbol)
33
-
34
- option_value = option_value.to_datetime if (defined?(ActiveSupport::TimeWithZone) and option_value.is_a? ActiveSupport::TimeWithZone)
33
+
34
+ # To enable to_i conversion, these types must be converted to Datetimes
35
+ if defined?(ActiveSupport::TimeWithZone)
36
+ option_value = option_value.to_datetime if option_value.is_a?(ActiveSupport::TimeWithZone)
37
+ value = value.to_datetime if value.is_a?(ActiveSupport::TimeWithZone)
38
+ end
39
+
40
+ if defined?(Date)
41
+ option_value = option_value.to_datetime if option_value.is_a?(Date)
42
+ value = value.to_datetime if value.is_a?(Date)
43
+ end
35
44
 
36
45
  unless is_time?(option_value) && value.to_i.send(CHECKS[option], option_value.to_i)
37
46
  record.errors.add(attr_name, option, :default => options[:message], :value => value, :date => option_value)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: date_validator
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 2
10
- version: 0.5.2
9
+ - 3
10
+ version: 0.5.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Oriol Gual
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-06-18 00:00:00 +02:00
20
+ date: 2010-06-20 00:00:00 +02:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency