Skip to content

Commit

Permalink
date in content types compatible with ruby 1.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
did committed Jan 10, 2011
1 parent 933c26d commit ff01539
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
8 changes: 4 additions & 4 deletions Gemfile.lock
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions lib/locomotive/import/content_types.rb
Expand Up @@ -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)
Expand Down
13 changes: 7 additions & 6 deletions lib/locomotive/liquid/filters/date.rb
Expand Up @@ -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
Expand Down

0 comments on commit ff01539

Please sign in to comment.