Sha256: 4b039ee06861026d58800ba6ba3f90ff4eebb604c46bbb5c9b29b3bdd5f42bdf

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

module Ramaze
  module CoreExtensions
    # Extensions for Numeric
    module Numeric
      def seconds
        self
      end
      alias second seconds

      # 60 seconds in a minute
      def minutes
        self * 60
      end
      alias minute minutes

      # 60 minutes in an hour
      def hours
        self * 3600
      end
      alias hour hours

      # 24 hours in a day
      def days
        self * 86400
      end
      alias day days

      # 7 days in a week
      def weeks
        self * 604800
      end
      alias week weeks

      # 30 days in a month
      def months
        self * 2592000
      end
      alias month months

      # 365.25 days in a year
      def years
        self * 31557600
      end
      alias year years

      # Time in the past, i.e. 3.days.ago
      def ago t = Time.now
        t - self
      end
      alias before ago

      # Time in the future, i.e. 3.days.from_now
      def from_now t = Time.now
        t + self
      end
      alias since from_now
    end # Numeric
  end # CoreExtensions
end # Ramaze

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ramaze-2012.04.14 lib/ramaze/snippets/numeric/time.rb
ramaze-2012.03.07 lib/ramaze/snippets/numeric/time.rb
ramaze-2011.12.28 lib/ramaze/snippets/numeric/time.rb
ramaze-2011.10.23 lib/ramaze/snippets/numeric/time.rb