- Timestamp:
- Oct 18, 2009, 8:14:21 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ruby/branches/0.5/lib/open_ehr/rm/data_types/quantity/date_time.rb
r311 r322 29 29 @value = value 30 30 end 31 32 undef magnitude= 31 33 end 32 34 … … 43 45 @day = iso8601_date.day 44 46 end 45 46 undef magnitude=47 47 48 48 def magnitude … … 89 89 90 90 class DvTime < DvTemporal 91 include OpenEHR::AssumedLibraryTypes::ISO8601TimeModule 92 def initialize(value, magnitude_status=nil, accuracy=nil, 93 normal_range=nil, normal_status=nil, 94 other_reference_range=nil) 95 super(value, magnitude_status, accuracy, normal_range, 96 normal_status, other_reference_range) 97 end 91 include ISO8601TimeModule 98 92 99 93 def value=(value) 100 94 super(value) 101 iso8601_time = AssumedLibraryTypes::ISO8601Time.new(value)95 iso8601_time = ISO8601Time.new(value) 102 96 @hour = iso8601_time.hour 103 97 @minute = iso8601_time.minute … … 124 118 class DvDateTime < DvTemporal 125 119 include OpenEHR::AssumedLibraryTypes::ISO8601DateTimeModule 126 attr_reader :value127 128 def initialize(value, magnitude_status=nil, accuracy=nil,129 normal_range=nil, normal_status=nil,130 other_reference_range=nil)131 super(value, magnitude_status, accuracy, normal_range,132 normal_status, other_reference_range)133 end134 120 135 121 def value=(value) … … 147 133 148 134 def magnitude 149 seconds = ::DateTime.new(@year,@month,@day,@hour,@minute,@second) - 150 ::DateTime.new(0000,1,1,0,0,0) 135 seconds = (((@year * 365.24 + 136 @month * 30.42 + 137 @day) * 24 + @hour) * 60 + 138 @minute) * 60 + @second 151 139 if @fractional_second.nil? 152 140 return seconds … … 155 143 end 156 144 end 157 158 undef magnitude=159 145 160 146 def diff(other) … … 175 161 minute = ((time_diff - hour*60*60)/60).to_i 176 162 second = (time_diff - hour * 60 *60 - minute * 60).to_i 177 fractional_second = ((time_diff - time_diff.to_i)*1000000.0).to_i/1000000.0178 163 fractional_second = 164 ((time_diff - time_diff.to_i)*1000000.0).to_i/1000000.0 179 165 return DvDuration.new(date_duration.value + 'T' + 180 166 hour.to_s + 'H' + 181 167 minute.to_s + 'M' + 182 168 second.to_s + fractional_second.to_s[1..-1] + 'S') 183 184 169 end 185 170
Note:
See TracChangeset
for help on using the changeset viewer.