Browse files

date in content types compatible with ruby 1.9.2

  • Loading branch information...
1 parent 933c26d commit ff01539bb586776deebbf975e53e3fcf30288547 @did did committed Jan 11, 2011
Showing with 12 additions and 10 deletions.
  1. +4 −4 Gemfile.lock
  2. +1 −0 lib/locomotive/import/content_types.rb
  3. +7 −6 lib/locomotive/liquid/filters/date.rb
View
8 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)
View
1 lib/locomotive/import/content_types.rb
@@ -73,6 +73,7 @@ def insert_samples(content_type, contents)
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)
View
13 lib/locomotive/liquid/filters/date.rb
@@ -4,16 +4,17 @@ module Filters
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

0 comments on commit ff01539

Please sign in to comment.