Class: Clock::UTC

Inherits:
Object
  • Object
show all
Includes:
Clock
Defined in:
lib/clock/utc.rb

Defined Under Namespace

Modules: Substitute

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Clock

#canonize, #elapsed_milliseconds, included, #iso8601, local, #now, #parse, #system_time, #timestamp, utc

Methods included from Now

#now

Methods included from Canonize

#canonize

Methods included from SystemTime

#system_time

Methods included from ISO8601

#iso8601, #precision

Methods included from Parse

#parse

Methods included from ElapsedMilliseconds

#elapsed_milliseconds

Methods included from Timestamp

#timestamp

Class Method Details

.canonize(time) ⇒ Object



5
6
7
# File 'lib/clock/utc.rb', line 5

def self.canonize(time, *)
  Clock.utc(time)
end

.coerce(time) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/clock/utc.rb', line 13

def self.coerce(time)
  if time.is_a? String
    time = Time.parse(time)
  end

  offset = time.gmt_offset

  utc_time = time.getutc

  utc_time = utc_time + offset

  now(utc_time)
end

Instance Method Details

#coerce(time) ⇒ Object



9
10
11
# File 'lib/clock/utc.rb', line 9

def coerce(time)
  self.class.shift(time)
end