Compare commits

..

4 Commits
1.1.4 ... 1.1.5

Author SHA1 Message Date
Adam Meehan
b3e235a8a1 release 1.1.5 2009-01-21 14:15:35 +11:00
Adam Meehan
71583805c8 fixed regex for yy format token which wasn't greedy enough when datetime string parsed as date causing a 4 digit year to be extracted as first 2 digits 2009-01-21 14:07:35 +11:00
Adam Meehan
2ee971623c whitespace 2009-01-21 14:07:20 +11:00
Adam Meehan
817e49940c removed the 'resume' call, um wtf? 2009-01-21 14:05:46 +11:00
7 changed files with 16 additions and 9 deletions

View File

@@ -1,3 +1,6 @@
= 1.1.5 [2009-01-21]
- Fixed regex for 'yy' format token which wasn't greedy enough for date formats ending with year when a datetime string parsed as date with a 4 digit year
= 1.1.4 [2009-01-13] = 1.1.4 [2009-01-13]
- Make months names respect i18n in Formats - Make months names respect i18n in Formats

View File

@@ -5,7 +5,7 @@ require 'date'
require 'spec/rake/spectask' require 'spec/rake/spectask'
GEM = "validates_timeliness" GEM = "validates_timeliness"
GEM_VERSION = "1.1.4" GEM_VERSION = "1.1.5"
AUTHOR = "Adam Meehan" AUTHOR = "Adam Meehan"
EMAIL = "adam.meehan@gmail.com" EMAIL = "adam.meehan@gmail.com"
HOMEPAGE = "http://github.com/adzap/validates_timeliness" HOMEPAGE = "http://github.com/adzap/validates_timeliness"

View File

@@ -53,11 +53,10 @@ module ValidatesTimeliness
def setup_for_rails def setup_for_rails
major, minor = Rails::VERSION::MAJOR, Rails::VERSION::MINOR major, minor = Rails::VERSION::MAJOR, Rails::VERSION::MINOR
self.send("setup_for_rails_#{major}_#{minor}")
self.default_timezone = ::ActiveRecord::Base.default_timezone self.default_timezone = ::ActiveRecord::Base.default_timezone
self.send("setup_for_rails_#{major}_#{minor}")
rescue rescue
puts "Rails version #{Rails::VERSION::STRING} not explicitly supported by validates_timeliness plugin. You may encounter some problems." puts "Rails version #{major}.#{minor}.x not explicitly supported by validates_timeliness plugin. You may encounter some problems."
resume
end end
end end
end end

View File

@@ -119,7 +119,7 @@ module ValidatesTimeliness
def define_write_method_for_dates_and_times(attr_name, type, time_zone_aware) def define_write_method_for_dates_and_times(attr_name, type, time_zone_aware)
method_body = <<-EOV method_body = <<-EOV
def #{attr_name}=(value) def #{attr_name}=(value)
write_date_time_attribute('#{attr_name}', value, #{type.inspect}, #{time_zone_aware}) write_date_time_attribute('#{attr_name}', value, #{type.inspect}, #{time_zone_aware})
end end
EOV EOV
evaluate_attribute_method attr_name, method_body, "#{attr_name}=" evaluate_attribute_method attr_name, method_body, "#{attr_name}="

View File

@@ -115,7 +115,7 @@ module ValidatesTimeliness
{ 'mm' => [ /m{2}/, '(\d{2})', :month ] }, { 'mm' => [ /m{2}/, '(\d{2})', :month ] },
{ 'm' => [ /(\A|[^ap])m{1}/, '(\d{1,2})', :month ] }, { 'm' => [ /(\A|[^ap])m{1}/, '(\d{1,2})', :month ] },
{ 'yyyy' => [ /y{4,}/, '(\d{4})', :year ] }, { 'yyyy' => [ /y{4,}/, '(\d{4})', :year ] },
{ 'yy' => [ /y{2,}/, '(\d{2}|\d{4})', :year ] }, { 'yy' => [ /y{2,}/, '(\d{4}|\d{2})', :year ] },
{ 'hh' => [ /h{2,}/, '(\d{2})', :hour ] }, { 'hh' => [ /h{2,}/, '(\d{2})', :hour ] },
{ 'h' => [ /h{1}/, '(\d{1,2})', :hour ] }, { 'h' => [ /h{1}/, '(\d{1,2})', :hour ] },
{ 'nn' => [ /n{2,}/, '(\d{2})', :min ] }, { 'nn' => [ /n{2,}/, '(\d{2})', :min ] },

View File

@@ -163,6 +163,11 @@ describe ValidatesTimeliness::Formats do
time_array.should == [2000,2,1,0,0,0,0] time_array.should == [2000,2,1,0,0,0,0]
end end
it "should ignore time when extracting date from format with trailing year and strict is false" do
time_array = formats.parse('01-02-2000 12:12', :date, false)
time_array.should == [2000,2,1,0,0,0,0]
end
it "should ignore date when extracting time and strict is false" do it "should ignore date when extracting time and strict is false" do
time_array = formats.parse('2000-02-01 12:12', :time, false) time_array = formats.parse('2000-02-01 12:12', :time, false)
time_array.should == [0,0,0,12,12,0,0] time_array.should == [0,0,0,12,12,0,0]

View File

@@ -2,12 +2,12 @@
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = %q{validates_timeliness} s.name = %q{validates_timeliness}
s.version = "1.1.4" s.version = "1.1.5"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Adam Meehan"] s.authors = ["Adam Meehan"]
s.autorequire = %q{validates_timeliness} s.autorequire = %q{validates_timeliness}
s.date = %q{2009-01-13} s.date = %q{2009-01-21}
s.description = %q{Date and time validation plugin for Rails 2.x which allows custom formats} s.description = %q{Date and time validation plugin for Rails 2.x which allows custom formats}
s.email = %q{adam.meehan@gmail.com} s.email = %q{adam.meehan@gmail.com}
s.extra_rdoc_files = ["README.rdoc", "LICENSE", "TODO", "CHANGELOG"] s.extra_rdoc_files = ["README.rdoc", "LICENSE", "TODO", "CHANGELOG"]