- Timestamp:
- Jan 21, 2010, 6:54:57 PM (14 years ago)
- Location:
- ruby/trunk
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
ruby/trunk/lib/open_ehr/am/archetype/constraint_model/primitive.rb
r397 r398 173 173 end 174 174 end 175 176 class CTime < CPrimitive 177 178 end 175 179 end # of Primitive 176 180 end # of CostraintModel -
ruby/trunk/lib/open_ehr/assumed_library_types.rb
r397 r398 135 135 136 136 module ISO8601DateModule 137 include Comparable138 137 attr_reader :year, :month, :day 139 138 … … 182 181 end 183 182 184 def <=>(other)185 (@year*TimeDefinitions::NOMINAL_DAYS_IN_YEAR +186 @month*TimeDefinitions::NOMINAL_DAYS_IN_MONTH + @day) <=>187 (other.year*TimeDefinitions::NOMINAL_DAYS_IN_YEAR +188 other.month*TimeDefinitions::NOMINAL_DAYS_IN_MONTH + other.month)189 end190 183 protected 191 184 def leapyear?(year) … … 198 191 end 199 192 193 def nilthenzero(value) 194 return value ? value : 0 195 end 196 200 197 class ISO8601Date < TimeDefinitions 201 include ISO8601DateModule 198 include ISO8601DateModule, Comparable 202 199 def initialize(string) 203 200 /(\d{4})(?:-(\d{2})(?:-(\d{2})?)?)?/ =~ string … … 217 214 self.day = $3.to_i 218 215 end 216 end 217 218 def <=>(other) 219 magnitude = 220 nilthenzero(@year)*TimeDefinitions::NOMINAL_DAYS_IN_YEAR + 221 nilthenzero(@month)*TimeDefinitions::NOMINAL_DAYS_IN_MONTH + 222 nilthenzero(@day) 223 other_magnitude = 224 nilthenzero(other.year)*TimeDefinitions::NOMINAL_DAYS_IN_YEAR + 225 nilthenzero(other.month)*TimeDefinitions::NOMINAL_DAYS_IN_MONTH + 226 nilthenzero(other.day) 227 magnitude <=> other_magnitude 219 228 end 220 229 … … 312 321 return s 313 322 end 323 324 314 325 end 315 326 316 327 class ISO8601Time < TimeDefinitions 317 include ISO8601TimeModule 328 include ISO8601TimeModule, Comparable 318 329 def initialize(string) 319 330 /(\d{2}):?(\d{2})?(:?)(\d{2})?((\.|,)(\d+))?(Z|([+-](\d{2}):?(\d{2})))?/ =~ string … … 343 354 self.timezone = $8 344 355 end 356 end 357 358 def <=>(other) 359 magnitude = (nilthenzero(@hour)*60 + nilthenzero(@minute))*60 + 360 nilthenzero(@second) + 361 nilthenzero(@fractional_second) 362 other_magnitude = (nilthenzero(other.hour) * 60 + 363 nilthenzero(other.minute)) * 60 + 364 nilthenzero(other.second) + 365 nilthenzero(other.fractional_second) 366 magnitude <=> other_magnitude 345 367 end 346 368 -
ruby/trunk/lib/open_ehr/rm/data_types/quantity/date_time.rb
r397 r398 181 181 end 182 182 183 def <=>(other)184 self.magnitude <=> other.magnitude185 end186 187 183 private 188 189 184 def split_date_time(date_time) 190 185 /^(.*)T(.*)$/ =~ date_time.as_string
Note:
See TracChangeset
for help on using the changeset viewer.