tracks/app/helpers/stats_helper.rb
Reinier Balt e58379e81f This fixes failing tests when the timezone is different than utc
There were several problems:
* Time.now returns the systems time, not the users time
* fixtures do not translate dates from timezone to utc, but stores the
  date verbatim
* calling a controller will set the timezone to the preference of the
  current_user. So it could be changed while you do not realize this. I
  fixed the failing test, but problems could be elsewhere
2015-08-05 11:50:33 +02:00

23 lines
527 B
Ruby

module StatsHelper
def font_size(cloud, tag)
9 + 2 * cloud.relative_size(tag)
end
def month_and_year_label(i)
t('date.month_names')[ (Time.zone.now.mon - i -1 ) % 12 + 1 ]+ " " + (Time.zone.now - i.months).year.to_s
end
def array_of_month_and_year_labels(count)
Array.new(count) { |i| month_and_year_label(i) }
end
def month_label(i)
t('date.month_names')[ (Time.zone.now.mon - i -1 ) % 12 + 1 ]
end
def array_of_month_labels(count)
Array.new(count) { |i| month_label(i) }
end
end