File: time.rb

package info (click to toggle)
ruby-origin 2.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 248 kB
  • sloc: ruby: 1,196; makefile: 3
file content (56 lines) | stat: -rw-r--r-- 1,272 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# 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)