module OpenEHR::AssumedLibraryTypes::ISO8601TimeModule

Attributes

fractional_second[R]
hour[R]
minute[R]
second[R]

Public Instance Methods

as_string() click to toggle source
# File lib/openehr/assumed_library_types.rb, line 362
def as_string
  s = sprintf("%02d", @hour)
  if !@minute.nil?
    s += ":" + sprintf("%02d",@minute)
    if !@second.nil?
      s += ":" + sprintf("%02d", @second)
      if !@fractional_second.nil?
        s += "." + @fractional_second.to_s[2..-1]
        if !@timezone.nil?
          s += @timezone.to_s
        end
      end
    end
  end
  return s
end
fractional_second=(fractional_second) click to toggle source
# File lib/openehr/assumed_library_types.rb, line 324
def fractional_second=(fractional_second)
  raise ArgumentError, "minute not defined" if minute_unknown? and !fractional_second.nil?
  raise ArgumentError, "second not defined" if second_unknown? and !fractional_second.nil?
  if !fractional_second.nil? &&
      (fractional_second < 0.0 || fractional_second >= 1.0)
    raise ArgumentError, 'fractional second should be between 0.0 - 1.0'
  end
  @fractional_second = fractional_second
end
has_fractional_second?() click to toggle source
# File lib/openehr/assumed_library_types.rb, line 334
def has_fractional_second?
  return !@fractional_second.nil?
end
hour=(hour) click to toggle source
# File lib/openehr/assumed_library_types.rb, line 298
def hour=(hour)
  unless TimeDefinitions.valid_hour?(hour, @minute, @second)
    raise ArgumentError, "hour is not valid"
  end
  @hour = hour
end
is_decimal_sign_comma?() click to toggle source
# File lib/openehr/assumed_library_types.rb, line 350
def is_decimal_sign_comma?
  false
end
is_extended?() click to toggle source
# File lib/openehr/assumed_library_types.rb, line 354
def is_extended?
  true
end
is_partial?() click to toggle source
# File lib/openehr/assumed_library_types.rb, line 358
def is_partial?
  second_unknown? or minute_unknown?
end
minute=(minute) click to toggle source
# File lib/openehr/assumed_library_types.rb, line 309
def minute=(minute)
  raise ArgumentError, "minute is not valid" if !minute.nil? and !TimeDefinitions.valid_minute?(minute)
  @minute = minute
end
minute_unknown?() click to toggle source
# File lib/openehr/assumed_library_types.rb, line 305
def minute_unknown?
  @minute.nil?
end
second=(second) click to toggle source
# File lib/openehr/assumed_library_types.rb, line 318
def second=(second)
  raise ArgumentError, "minute not defined" if @minute.nil? and !second.nil?
  raise ArgumentError, "second is not valid" if !second.nil? and !TimeDefinitions.valid_second?(second)
  @second = second
end
second_unknown?() click to toggle source
# File lib/openehr/assumed_library_types.rb, line 314
def second_unknown?
  @second.nil?
end
timezone() click to toggle source
# File lib/openehr/assumed_library_types.rb, line 346
def timezone
  @timezone.to_s
end
timezone=(timezone) click to toggle source
# File lib/openehr/assumed_library_types.rb, line 338
def timezone=(timezone)
  unless timezone.nil? or timezone.empty?
    @timezone = Timezone.new(timezone)
  else
    @timezone = nil
  end
end
to_second() click to toggle source
# File lib/openehr/assumed_library_types.rb, line 379
def to_second
  second = (nilthenzero(@hour)*60 + nilthenzero(@minute))*60 +
    nilthenzero(@second) +
    nilthenzero(@fractional_second)
  return second
end