Method: OpenEHR::AssumedLibraryTypes::ISO8601DateTimeModule#as_string

Defined in:
lib/openehr/assumed_library_types.rb

#as_stringObject



467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
# File 'lib/openehr/assumed_library_types.rb', line 467

def as_string
  if (!@year.nil? and !@month.nil? and !@day.nil?)
    s = Date.new(@year, @month, @day).to_s
  elsif (!@year.nil? and !@month.nil? and @day.nil?)
    return Date.new(@year, @month).to_s[0,7]
  elsif (!@year.nil? and @month.nil? and @day.nil?)
    return Date.new(@year).to_s[0,4]
  end
  unless hour.nil?
    s += sprintf("T%02d", @hour)
    unless @minute.nil?
      s += ":" + sprintf("%02d",@minute)
      unless @second.nil?
        s += ":" + sprintf("%02d", @second)
        unless @fractional_second.nil?
          s += "." + @fractional_second.to_s[2..-1]
        end
      end
    end
    unless @timezone.nil?
      s += @timezone.to_s
    end
  end
  return s
end