calculate_unit

in lib/twitter_cldr/localized/localized_timespan.rb [44:57]


      def calculate_unit(seconds, options = {})
        approximate = options[:approximate]
        approximate = false if approximate.nil?
        multiplier = approximate ? APPROXIMATE_MULTIPLIER : 1

        if seconds < (TIME_IN_SECONDS[:minute] * multiplier) then :second
        elsif seconds < (TIME_IN_SECONDS[:hour] * multiplier) then :minute
        elsif seconds < (TIME_IN_SECONDS[:day] * multiplier) then :hour
        elsif seconds < (TIME_IN_SECONDS[:week] * multiplier) then :day
        elsif seconds < (TIME_IN_SECONDS[:month] * multiplier) then :week
        elsif seconds < (TIME_IN_SECONDS[:year] * multiplier) then :month
        else :year end
      end