class OpenEHR::RM::DataTypes::Quantity::DateTime::DvTime

Public Instance Methods

diff(other) click to toggle source
# File lib/openehr/rm/data_types/quantity/date_time.rb, line 115
def diff(other)
  diff = (other.magnitude - self.magnitude).abs
  hour = (diff / 60 / 60).to_i
  minute = ((diff - hour*60*60)/60).to_i
  second = (diff - hour * 60 *60 - minute * 60).to_i
  fractional_second = ((diff - diff.to_i)*1000000.0).to_i/1000000.0
  str = 'P0Y0M0W0DT' + hour.to_s + 'H' +
    minute.to_s + 'M' + second.to_s
  if @fractional_second.nil?
    str += 'S'
  else
    str += fractional_second.to_s[1..-1] + 'S'
  end
  return DvDuration.new(:value => str)
end
magnitude() click to toggle source
# File lib/openehr/rm/data_types/quantity/date_time.rb, line 103
def magnitude
  if @fractional_second.nil? && @second.nil? && @minute.nil?
    return @hour * 60 * 60
  elsif @fractional_second.nil? && @second.nil?
    return @hour * 60 * 60 + @minute * 60
  elsif @fractional_second.nil?
    return @hour * 60 * 60 + @minute * 60 + @second
  else
    return @hour*60*60+@minute* 60 + @second + @fractional_second
  end
end
value=(value) click to toggle source
# File lib/openehr/rm/data_types/quantity/date_time.rb, line 93
def value=(value)
  super(value)
  iso8601_time = OpenEHR::AssumedLibraryTypes::ISO8601Time.new(value)
  @hour = iso8601_time.hour
  @minute = iso8601_time.minute
  @second = iso8601_time.second
  @fractional_second = iso8601_time.fractional_second
  @timezone = iso8601_time.timezone
end