Class: OpenEHR::AssumedLibraryTypes::ISO8601DateTime
- Inherits:
-
Object
- Object
- OpenEHR::AssumedLibraryTypes::ISO8601DateTime
- Includes:
- ISO8601DateTimeModule
- Defined in:
- lib/open_ehr/assumed_library_types.rb
Constant Summary
Constants included from TimeDefinitions
TimeDefinitions::DAYS_IN_LEAP_YEAR, 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?, #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.
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 |
# File 'lib/open_ehr/assumed_library_types.rb', line 490 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
533 534 535 |
# File 'lib/open_ehr/assumed_library_types.rb', line 533 def <=>(other) self.magnitude <=> other.magnitude end |