- Timestamp:
- Nov 12, 2009, 1:43:18 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ruby/branches/0.5/lib/open_ehr/rm/data_types/quantity/date_time.rb
r342 r343 100 100 101 101 def magnitude 102 return @hour * 60 * 60 + @minute * 60 + @second + @fractional_second 102 if @fractional_second.nil? 103 return @hour * 60 * 60 + @minute * 60 + @second 104 else 105 return @hour * 60 * 60 + @minute * 60 + @second + @fractional_second 106 end 103 107 end 104 108 … … 109 113 second = (diff - hour * 60 *60 - minute * 60).to_i 110 114 fractional_second = ((diff - diff.to_i)*1000000.0).to_i/1000000.0 111 return DvDuration.new(:value => 112 'P0Y0M0W0DT' + hour.to_s + 'H' + 113 minute.to_s + 'M' + 114 second.to_s + fractional_second.to_s[1..-1] + 'S') 115 str = 'P0Y0M0W0DT' + hour.to_s + 'H' + 116 minute.to_s + 'M' + second.to_s 117 if @fractional_second.nil? 118 str += 'S' 119 else 120 str += fractional_second.to_s[1..-1] + 'S' 121 end 122 return DvDuration.new(:value => str) 115 123 end 116 124 end … … 161 169 minute = ((time_diff - hour*60*60)/60).to_i 162 170 second = (time_diff - hour * 60 *60 - minute * 60).to_i 163 fractional_second = 164 ((time_diff - time_diff.to_i)*1000000.0).to_i/1000000.0 165 return DvDuration.new(:value => 166 date_duration.value + 'T' + 167 hour.to_s + 'H' + 168 minute.to_s + 'M' + 169 second.to_s + fractional_second.to_s[1..-1] + 'S') 171 str = date_duration.value + 'T' + hour.to_s + 'H' + 172 minute.to_s + 'M' + second.to_s 173 if @fractional_second.nil? 174 return DvDuration.new(:value => str +'S') 175 else 176 fractional_second = 177 ((time_diff - time_diff.to_i)*1000000.0).to_i/1000000.0 178 return DvDuration.new(:value => str + 179 fractional_second.to_s[1..-1] + 'S') 180 end 170 181 end 171 182 … … 174 185 def split_date_time(date_time) 175 186 /^(.*)T(.*)$/ =~ date_time.as_string 176 return DvDate.new( $1), DvTime.new($2)187 return DvDate.new(:value => $1), DvTime.new(:value => $2) 177 188 end 178 189 end
Note:
See TracChangeset
for help on using the changeset viewer.