Class: Tai64::Time

Inherits:
Object
  • Object
show all
Includes:
Fudge
Defined in:
lib/tai64.rb

Instance Method Summary collapse

Methods included from Fudge

included

Constructor Details

#initialize(time) ⇒ Time

Returns a new instance of Time.



37
38
39
# File 'lib/tai64.rb', line 37

def initialize time
  self.time = time
end

Instance Method Details

#tai_nanosecondObject



53
54
55
# File 'lib/tai64.rb', line 53

def tai_nanosecond
  utc_nanosecond + nano_second_fudge
end

#tai_secondObject



45
46
47
# File 'lib/tai64.rb', line 45

def tai_second
  utc_second + 10
end

#to_labelObject

Warning, this will probably gain inappropriate accuracy - Ruby does not support the same level of timing accuracy as TAI64N and TA64NA can provide.



60
61
62
63
64
65
66
67
68
69
# File 'lib/tai64.rb', line 60

def to_label
  s = '%016x%08x'
  sec = tai_second
  ts = if sec >= 0
    sec + EPOCH
  else
    EPOCH - sec
  end
  Label.new s % [ ts, tai_nanosecond ]
end

#to_sObject



71
72
73
# File 'lib/tai64.rb', line 71

def to_s
  time.to_s
end

#utc_nanosecondObject



49
50
51
# File 'lib/tai64.rb', line 49

def utc_nanosecond
  time.to_f - time.to_i
end

#utc_secondObject



41
42
43
# File 'lib/tai64.rb', line 41

def utc_second
  time.to_i
end