Class: OpenEHR::AssumedLibraryTypes::ISO8601DateTime
- Inherits:
-
Object
- Object
- OpenEHR::AssumedLibraryTypes::ISO8601DateTime
- Includes:
- Comparable, ISO8601DateTimeModule
- Defined in:
- lib/openehr/assumed_library_types.rb
Constant Summary
Constants included from TimeDefinitions
TimeDefinitions::DAYS_IN_LEAP_YEAR, TimeDefinitions::DAYS_IN_MONTH, TimeDefinitions::DAYS_IN_WEEK, TimeDefinitions::DAYS_IN_YEAR, TimeDefinitions::HOURS_IN_DAY, TimeDefinitions::MAX_DAYS_IN_MONTH, TimeDefinitions::MAX_DAYS_IN_YEAR, TimeDefinitions::MINUTES_IN_HOUR, TimeDefinitions::MONTH_IN_YEAR, TimeDefinitions::NOMINAL_DAYS_IN_MONTH, TimeDefinitions::NOMINAL_DAYS_IN_YEAR, TimeDefinitions::SECONDS_IN_MINUTE
Instance Attribute Summary
Attributes included from ISO8601DateModule
Attributes included from ISO8601TimeModule
#fractional_second, #hour, #minute, #second
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(string) ⇒ ISO8601DateTime
constructor
A new instance of ISO8601DateTime.
Methods included from ISO8601DateTimeModule
Methods included from ISO8601DateModule
#as_string, #day_unknown?, #is_extended?, #is_partial?, #leapyear?, #month_unknown?, #to_days
Methods included from TimeDefinitions
valid_day?, valid_hour?, valid_minute?, valid_month?, valid_second?, valid_year?
Methods included from ISO8601TimeModule
#as_string, #has_fractional_second?, #is_decimal_sign_comma?, #is_extended?, #is_partial?, #minute_unknown?, #second_unknown?, #timezone, #timezone=, #to_second
Constructor Details
#initialize(string) ⇒ ISO8601DateTime
Returns a new instance of ISO8601DateTime.
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 |
# File 'lib/openehr/assumed_library_types.rb', line 528 def initialize(string) unless /(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?T(\d{2})(?::(\d{2})(?::(\d{2})(?:(\.|,)(\d+))?)?(Z|([+-]\d{2}):?(\d{2}))?)?/ =~ string raise ArgumentError, 'format invalid' else self.year = $1.to_i end if $2.nil? self.month = nil else self.month = $2.to_i end if $3.nil? self.day = nil else self.day = $3.to_i end if $5.nil? self.minute = nil else self.minute = $5.to_i end if $6.nil? self.second = nil else self.second = $6.to_i end if $4.nil? self.hour = nil else self.hour = $4.to_i end if $8.nil? or $8.empty? self.fractional_second = nil else self.fractional_second = ("0."+$8).to_f end if $9.nil? self.timezone = nil else self.timezone = $9 end end |
Instance Method Details
#<=>(other) ⇒ Object
571 572 573 |
# File 'lib/openehr/assumed_library_types.rb', line 571 def <=>(other) self.magnitude <=> other.magnitude end |