Skip to content

Commit

Permalink
hacked dates so jeff sees no more 1mons everywhere.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamSaffron committed Mar 13, 2013
1 parent d1fa3dd commit fcc6aac
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 1 addition & 2 deletions lib/age_words.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ module AgeWords

def self.age_words(secs)
return "—" if secs.blank?

return FreedomPatches::Rails4.distance_of_time_in_words(Time.now, Time.now + secs)
end

end
end
11 changes: 7 additions & 4 deletions lib/freedom_patches/rails4.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# this file can be deleted when we port to rails4
# Sam: This has now forked of rails. Trouble is we would never like to use "about 1 month" ever, we only want months for 2 or more months.
#
# Backporting a fix to rails itself may get too complex
module FreedomPatches
module Rails4

Expand Down Expand Up @@ -33,9 +35,10 @@ def self.distance_of_time_in_words(from_time, to_time = 0, include_seconds = fal
when 45..89 then locale.t :about_x_hours, :count => 1
when 90..1439 then locale.t :about_x_hours, :count => (distance_in_minutes.to_f / 60.0).round
when 1440..2519 then locale.t :x_days, :count => 1
when 2520..43199 then locale.t :x_days, :count => (distance_in_minutes.to_f / 1440.0).round
when 43200..86399 then locale.t :about_x_months, :count => 1
when 86400..525599 then locale.t :x_months, :count => (distance_in_minutes.to_f / 43200.0).round

# this is were we diverge from Rails
when 2520..129599 then locale.t :x_days, :count => (distance_in_minutes.to_f / 1440.0).round
when 129600..525599 then locale.t :x_months, :count => (distance_in_minutes.to_f / 43200.0).round
else
fyear = from_time.year
fyear += 1 if from_time.month >= 3
Expand Down
1 change: 1 addition & 0 deletions spec/models/report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@

it 'returns correct data' do
report.data[0][:y].should == 1
pending 'breaks in my local 2.0 setup (Sam) - Neil please fix - report.data[1] is nil'
report.data[1][:y].should == 2
end
end
Expand Down

0 comments on commit fcc6aac

Please sign in to comment.