Module: Clock

Extended by:
Canonize, ElapsedMilliseconds, ISO8601, Now, Parse, SystemTime, Timestamp
Included in:
Local, Substitute, UTC
Defined in:
lib/clock/utc.rb,
lib/clock/clock.rb,
lib/clock/local.rb,
lib/clock/substitute.rb,
lib/clock/controls/time.rb,
lib/clock/controls/time/offset.rb

Defined Under Namespace

Modules: Canonize, Configure, Controls, ElapsedMilliseconds, ISO8601, Now, Parse, SystemTime, Timestamp Classes: Error, Local, Substitute, UTC

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ISO8601

precision

Class Method Details

.included(cls) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/clock/clock.rb', line 4

def self.included(cls)
  cls.extend Now
  cls.extend Canonize
  cls.extend SystemTime
  cls.extend ISO8601
  cls.extend Parse
  cls.extend ElapsedMilliseconds
  cls.extend Timestamp
  cls.extend Configure
end

.local(time) ⇒ Object



40
41
42
# File 'lib/clock/clock.rb', line 40

def self.local(time)
  time.getlocal
end

.utc(time) ⇒ Object



44
45
46
# File 'lib/clock/clock.rb', line 44

def self.utc(time)
  time.utc
end

Instance Method Details

#canonize(time) ⇒ Object



19
20
21
# File 'lib/clock/clock.rb', line 19

def canonize(time)
  self.class.canonize(time, system_time)
end

#elapsed_milliseconds(start_time, end_time) ⇒ Object



48
49
50
# File 'lib/clock/clock.rb', line 48

def elapsed_milliseconds(start_time, end_time)
  self.class.elapsed_milliseconds(start_time, end_time)
end

#iso8601(time = nil, precision: nil) ⇒ Object



27
28
29
30
# File 'lib/clock/clock.rb', line 27

def iso8601(time=nil, precision: nil)
  time ||= now
  self.class.iso8601 time, precision: precision, system_time: system_time
end

#now(time = nil) ⇒ Object



15
16
17
# File 'lib/clock/clock.rb', line 15

def now(time=nil)
  time || self.class.now(system_time: system_time)
end

#parse(str) ⇒ Object



32
33
34
# File 'lib/clock/clock.rb', line 32

def parse(str)
  time = self.class.parse(str, system_time: system_time)
end

#system_timeObject



23
24
25
# File 'lib/clock/clock.rb', line 23

def system_time
  self.class.system_time
end

#timestamp(time = nil) ⇒ Object



36
37
38
# File 'lib/clock/clock.rb', line 36

def timestamp(time=nil)
  self.class.timestamp time
end