Class: OpenEHR::RM::DataTypes::Quantity::DateTime::DvTime
- Inherits:
-
DvTemporal
- Object
- Basic::DataValue
- OpenEHR::RM::DataTypes::Quantity::DvOrdered
- OpenEHR::RM::DataTypes::Quantity::DvQuantified
- OpenEHR::RM::DataTypes::Quantity::DvAbsoluteQuantity
- DvTemporal
- OpenEHR::RM::DataTypes::Quantity::DateTime::DvTime
- Includes:
- ISO8601TimeModule
- Defined in:
- lib/open_ehr/rm/data_types/quantity/date_time.rb
Constant Summary
Constants included from Support::Definition::BasicDefinition
Support::Definition::BasicDefinition::CR, Support::Definition::BasicDefinition::LF
Instance Attribute Summary
Attributes inherited from OpenEHR::RM::DataTypes::Quantity::DvAbsoluteQuantity
Attributes inherited from OpenEHR::RM::DataTypes::Quantity::DvQuantified
Attributes inherited from OpenEHR::RM::DataTypes::Quantity::DvOrdered
#normal_range, #normal_status, #other_refference_ranges
Attributes inherited from Basic::DataValue
Instance Method Summary collapse
Methods inherited from DvTemporal
Methods inherited from OpenEHR::RM::DataTypes::Quantity::DvAbsoluteQuantity
Methods inherited from OpenEHR::RM::DataTypes::Quantity::DvQuantified
#<=>, #accuracy_unknown?, #initialize, valid_magnitude_status?
Methods inherited from OpenEHR::RM::DataTypes::Quantity::DvOrdered
#<=>, #initialize, #is_normal?, #is_simple?, #is_strictly_comparable_to?, #other_reference_ranges=
Methods inherited from Basic::DataValue
Constructor Details
This class inherits a constructor from OpenEHR::RM::DataTypes::Quantity::DateTime::DvTemporal
Instance Method Details
#diff(other) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/open_ehr/rm/data_types/quantity/date_time.rb', line 109 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 ⇒ Object
101 102 103 104 105 106 107 |
# File 'lib/open_ehr/rm/data_types/quantity/date_time.rb', line 101 def magnitude if @fractional_second.nil? return @hour * 60 * 60 + @minute * 60 + @second else return @hour * 60 * 60 + @minute * 60 + @second + @fractional_second end end |
#value=(value) ⇒ Object
92 93 94 95 96 97 98 99 |
# File 'lib/open_ehr/rm/data_types/quantity/date_time.rb', line 92 def value=(value) super(value) iso8601_time = ISO8601Time.new(value) @hour = iso8601_time.hour @minute = iso8601_time.minute @second = iso8601_time.second @fractional_second = iso8601_time.fractional_second end |