From 3f72f31063cb538da0c2413cf199a6658ee28480 Mon Sep 17 00:00:00 2001 From: Adam Meehan Date: Mon, 11 Oct 2010 13:12:16 +1100 Subject: [PATCH] change shorthand values to current timezone (thanks rpbertp13) --- README.rdoc | 2 +- .../validates_timeliness/templates/validates_timeliness.rb | 4 ++-- lib/validates_timeliness.rb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.rdoc b/README.rdoc index 2fbeda8..658e2ef 100644 --- a/README.rdoc +++ b/README.rdoc @@ -197,7 +197,7 @@ See the wiki[http://github.com/adzap/validates_timeliness/wiki/Plugin-Parser] fo === Restriction Shorthand It is common to restrict an attribute to being on or before the current time or current day. -To specify this you need to use a lambda as an option value e.g. lambda { Time.now }. +To specify this you need to use a lambda as an option value e.g. lambda { Time.current }. This can be tedious noise amongst your validations for something so common. To combat this the plugin allows you to use shorthand symbols for often used relative times or dates. diff --git a/lib/generators/validates_timeliness/templates/validates_timeliness.rb b/lib/generators/validates_timeliness/templates/validates_timeliness.rb index b58eb01..fbf9b41 100644 --- a/lib/generators/validates_timeliness/templates/validates_timeliness.rb +++ b/lib/generators/validates_timeliness/templates/validates_timeliness.rb @@ -19,8 +19,8 @@ ValidatesTimeliness.setup do |config| # # Shorthand date and time symbols for restrictions # config.restriction_shorthand_symbols.update( - # :now => lambda { Time.now }, - # :today => lambda { Date.today } + # :now => lambda { Time.current }, + # :today => lambda { Date.current } # ) # # Use the plugin date/time parser which is stricter and extendable diff --git a/lib/validates_timeliness.rb b/lib/validates_timeliness.rb index aae4478..528140c 100644 --- a/lib/validates_timeliness.rb +++ b/lib/validates_timeliness.rb @@ -35,8 +35,8 @@ module ValidatesTimeliness # Shorthand time and date symbols for restrictions mattr_accessor :restriction_shorthand_symbols @@restriction_shorthand_symbols = { - :now => lambda { Time.now }, - :today => lambda { Date.today } + :now => lambda { Time.current }, + :today => lambda { Date.current } } def self.parser