diff --git a/Gemfile.lock b/Gemfile.lock index f6cfe7a8..e006a541 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -42,7 +42,7 @@ GEM arel (2.0.6) autotest (4.4.6) ZenTest (>= 4.4.1) - bcrypt-ruby (2.1.3) + bcrypt-ruby (2.1.4) bson (1.1.5) bson_ext (1.1.5) builder (2.1.2) @@ -55,7 +55,7 @@ GEM rack-test (>= 0.5.4) selenium-webdriver (>= 0.0.27) xpath (~> 0.1.2) - celerity (0.8.6) + celerity (0.8.7) childprocess (0.1.6) ffi (~> 0.6.3) closure-compiler (0.3.3) @@ -89,7 +89,7 @@ GEM diff-lcs (1.1.2) erubis (2.6.6) abstract (>= 1.0.0) - excon (0.3.7) + excon (0.3.8) factory_girl (1.3.2) factory_girl_rails (1.0.1) factory_girl (~> 1.3) @@ -244,7 +244,7 @@ GEM warden (0.10.7) rack (>= 1.0.0) will_paginate (3.0.pre2) - xpath (0.1.2) + xpath (0.1.3) nokogiri (~> 1.3) yard (0.6.4) yui-compressor (0.9.1) diff --git a/lib/locomotive/import/content_types.rb b/lib/locomotive/import/content_types.rb index 89c2640d..0983d083 100644 --- a/lib/locomotive/import/content_types.rb +++ b/lib/locomotive/import/content_types.rb @@ -73,6 +73,7 @@ module Locomotive value = (case field.kind.downcase when 'file' then self.open_sample_asset(value) when 'boolean' then Boolean.set(value) + when 'date' then Date.parse(value) else value end) diff --git a/lib/locomotive/liquid/filters/date.rb b/lib/locomotive/liquid/filters/date.rb index f00b4ce5..d9ec339b 100644 --- a/lib/locomotive/liquid/filters/date.rb +++ b/lib/locomotive/liquid/filters/date.rb @@ -4,16 +4,17 @@ module Locomotive module Date def localized_date(input, *args) - format, locale = args[0], args[1] rescue 'en' + format, locale = args[0], args[1] || 'en' - date = input.is_a?(String) ? Time.parse(input) : input + return input.to_s if format.to_s.empty? - if format.to_s.empty? - return input.to_s + if input.is_a?(String) + fragments = ::Date._strptime(input, I18n.t('date.formats.default')) + date = ::Date.new(fragments[:year], fragments[:mon], fragments[:mday]) + else + date = input end - date = input.is_a?(String) ? Time.parse(input) : input - if date.respond_to?(:strftime) I18n.locale = locale I18n.l date, :format => format