Symphony::Metronome::

TimeFunctions module

Functions for time calculations

Public Instance Methods

calculate_seconds( count, unit )

Calculate the (approximate) number of seconds that are in count of the given unit of time.

# File lib/symphony/metronome/mixins.rb, line 20
def calculate_seconds( count, unit )
        return case unit
        when :seconds, :second
                count
        when :minutes, :minute
                count * 60
        when :hours, :hour
                count * 3600
        when :days, :day
                count * 86400
        when :weeks, :week
                count * 604800
        when :fortnights, :fortnight
                count * 1209600
        when :months, :month
                count * 2592000
        when :years, :year
                count * 31557600
        else
                raise ArgumentError, "don't know how to calculate seconds in a %p" % [ unit ]
        end
end