Sha256: 1a4ac5ec2adbc3686011dac42f78fd4aaf74024f93d306a26d8d694fbdead7d7

Contents?: true

Size: 1.24 KB

Versions: 26

Compression:

Stored size: 1.24 KB

Contents

# encoding: utf-8
module Origin
  module Extensions

    # This module contains additional time behaviour.
    module Time

      # Evolve the time as a date, UTC midnight.
      #
      # @example Evolve the time to a date query format.
      #   time.__evolve_date__
      #
      # @return [ Time ] The date at midnight UTC.
      #
      # @since 1.0.0
      def __evolve_date__
        ::Time.utc(year, month, day, 0, 0, 0, 0)
      end

      # Evolve the time into a utc time.
      #
      # @example Evolve the time.
      #   time.__evolve_time__
      #
      # @return [ Time ] The time in UTC.
      #
      # @since 1.0.0
      def __evolve_time__
        utc
      end

      module ClassMethods

        # Evolve the object to an date.
        #
        # @example Evolve dates.
        #
        # @example Evolve string dates.
        #
        # @example Evolve date ranges.
        #
        # @param [ Object ] object The object to evolve.
        #
        # @return [ Time ] The evolved date time.
        #
        # @since 1.0.0
        def evolve(object)
          object.__evolve_time__
        end
      end
    end
  end
end

::Time.__send__(:include, Origin::Extensions::Time)
::Time.__send__(:extend, Origin::Extensions::Time::ClassMethods)

Version data entries

26 entries across 25 versions & 4 rubygems

Version Path
origin-2.3.1 lib/origin/extensions/time.rb
origin-2.3.0 lib/origin/extensions/time.rb
origin-2.2.2 lib/origin/extensions/time.rb
origin-2.2.1 lib/origin/extensions/time.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/origin-2.2.0/lib/origin/extensions/time.rb
origin-2.2.0 lib/origin/extensions/time.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/origin-2.1.1/lib/origin/extensions/time.rb
tdiary-4.2.1 vendor/bundle/ruby/2.3.0/gems/origin-2.1.1/lib/origin/extensions/time.rb
origin-2.1.1 lib/origin/extensions/time.rb
origin-2.1.0 lib/origin/extensions/time.rb
origin-2.0.0 lib/origin/extensions/time.rb
origin-1.1.0 lib/origin/extensions/time.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/origin-1.0.11/lib/origin/extensions/time.rb
origin-1.0.11 lib/origin/extensions/time.rb
origin-1.0.10 lib/origin/extensions/time.rb
origin-1.0.9 lib/origin/extensions/time.rb
origin-1.0.8 lib/origin/extensions/time.rb
origin-1.0.7 lib/origin/extensions/time.rb
origin-1.0.6 lib/origin/extensions/time.rb
origin-1.0.4 lib/origin/extensions/time.rb