Module: OpenEHR::AssumedLibraryTypes::ISO8601DurationModule

Includes:
TimeDefinitions
Included in:
ISO8601Duration, RM::DataTypes::Quantity::DateTime::DvDuration
Defined in:
lib/openehr/assumed_library_types.rb

Overview

end of ISO8601Timezone

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 collapse

Instance Method Summary collapse

Methods included from TimeDefinitions

valid_day?, valid_hour?, valid_minute?, valid_month?, valid_second?, valid_year?

Instance Attribute Details

#daysObject

Returns the value of attribute days.



590
591
592
# File 'lib/openehr/assumed_library_types.rb', line 590

def days
  @days
end

#fractional_secondObject

Returns the value of attribute fractional_second.



591
592
593
# File 'lib/openehr/assumed_library_types.rb', line 591

def fractional_second
  @fractional_second
end

#hoursObject

Returns the value of attribute hours.



591
592
593
# File 'lib/openehr/assumed_library_types.rb', line 591

def hours
  @hours
end

#minutesObject

Returns the value of attribute minutes.



591
592
593
# File 'lib/openehr/assumed_library_types.rb', line 591

def minutes
  @minutes
end

#monthsObject

Returns the value of attribute months.



590
591
592
# File 'lib/openehr/assumed_library_types.rb', line 590

def months
  @months
end

#secondsObject

Returns the value of attribute seconds.



591
592
593
# File 'lib/openehr/assumed_library_types.rb', line 591

def seconds
  @seconds
end

#weeksObject

Returns the value of attribute weeks.



590
591
592
# File 'lib/openehr/assumed_library_types.rb', line 590

def weeks
  @weeks
end

#yearsObject

Returns the value of attribute years.



590
591
592
# File 'lib/openehr/assumed_library_types.rb', line 590

def years
  @years
end

Instance Method Details

#as_stringObject



649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
# File 'lib/openehr/assumed_library_types.rb', line 649

def as_string
  str = 'P'
  unless @years.nil?
    str += @years.to_s + 'Y'
  end
  unless @months.nil?
    str += @months.to_s + 'M'
  end
  unless @weeks.nil?
    str += @weeks.to_s + 'W'
  end
  unless @days.nil?
    str += @days.to_s + 'D'
  end
  unless @hours.nil?
    str += 'T' + @hours.to_s + 'H'
    unless @minutes.nil?
      str += @minutes.to_s + 'M'
      unless @seconds.nil?
        str += @seconds.to_s
        unless @fractional_second.nil?
          str += @fractional_second.to_s[1 .. -1]
        end
        str += 'S'
      end
    end
  end
  return str
end

#to_secondsObject



679
680
681
682
683
684
685
686
687
688
# File 'lib/openehr/assumed_library_types.rb', line 679

def to_seconds
  days = nilthenzero(@years)*TimeDefinitions::DAYS_IN_YEAR +
    nilthenzero(@months)*TimeDefinitions::DAYS_IN_MONTH +
    nilthenzero(@weeks)*TimeDefinitions::DAYS_IN_WEEK + 
    nilthenzero(@days)
  seconds_with_fractional = (((days*TimeDefinitions::HOURS_IN_DAY + nilthenzero(@hours))*TimeDefinitions::MINUTES_IN_HOUR)+nilthenzero(@minutes))*TimeDefinitions::SECONDS_IN_MINUTE + 
    nilthenzero(@seconds) +
    @fractional_second.to_f
  return seconds_with_fractional
end