lib/timeliness/helpers.rb in timeliness-0.3.3 vs lib/timeliness/helpers.rb in timeliness-0.3.4

- old
+ new

@@ -25,15 +25,15 @@ return month.to_i if month.to_i > 0 month.length > 3 ? month_names.index(month.capitalize) : abbr_month_names.index(month.capitalize) end def month_names - defined?(I18n) ? I18n.t('date.month_names') : Date::MONTHNAMES + i18n_loaded? ? I18n.t('date.month_names') : Date::MONTHNAMES end def abbr_month_names - defined?(I18n) ? I18n.t('date.abbr_month_names') : Date::ABBR_MONTHNAMES + i18n_loaded? ? I18n.t('date.abbr_month_names') : Date::ABBR_MONTHNAMES end def microseconds(usec) (".#{usec}".to_f * 1_000_000).to_i end @@ -41,9 +41,13 @@ def offset_in_seconds(offset) sign = offset =~ /^-/ ? -1 : 1 parts = offset.scan(/\d\d/).map {|p| p.to_f } parts[1] = parts[1].to_f / 60 (parts[0] + parts[1]) * sign * 3600 + end + + def i18n_loaded? + defined?(I18n) end end end