module OpenEHR::AssumedLibraryTypes::TimeDefinitions

Constants

DAYS_IN_LEAP_YEAR
DAYS_IN_MONTH
DAYS_IN_WEEK
DAYS_IN_YEAR
HOURS_IN_DAY
MAX_DAYS_IN_MONTH
MAX_DAYS_IN_YEAR
MINUTES_IN_HOUR
MONTH_IN_YEAR
NOMINAL_DAYS_IN_MONTH
NOMINAL_DAYS_IN_YEAR
SECONDS_IN_MINUTE

Public Class Methods

valid_day?(y, m, d) click to toggle source
# File lib/openehr/assumed_library_types.rb, line 153
def self.valid_day?(y, m, d)
  unless y.nil? || m.nil? || d.nil?
    return Date.valid_date?(y,m,d)
  end
  if (y.nil?) || (m.nil? && !d.nil?)
    return false
  end
  return self.valid_year?(y) && self.valid_month?(m)
end
valid_hour?(h,m = nil, s = nil) click to toggle source
# File lib/openehr/assumed_library_types.rb, line 163
def self.valid_hour?(h,m = nil, s = nil)
  if h.nil?
    return false
  end
  if !m.nil? and !valid_minute?(m)
    return false
  end
  if !s.nil? and (!m.nil? and !valid_second?(s))
    return false
  end
  (h >= 0 and h < HOURS_IN_DAY) or (h == HOURS_IN_DAY and m == 0 and s == 0)
end
valid_minute?(mi) click to toggle source
# File lib/openehr/assumed_library_types.rb, line 176
def self.valid_minute?(mi)
  mi >= 0 and mi < MINUTES_IN_HOUR
end
valid_month?(mo) click to toggle source
# File lib/openehr/assumed_library_types.rb, line 184
def self.valid_month?(mo)
  mo >= 1 and mo <= MONTH_IN_YEAR
end
valid_second?(s) click to toggle source
# File lib/openehr/assumed_library_types.rb, line 180
def self.valid_second?(s)
  s >= 0 and s < SECONDS_IN_MINUTE
end
valid_year?(year) click to toggle source
# File lib/openehr/assumed_library_types.rb, line 149
def self.valid_year?(year)
  return !year.nil? && year >= 0
end

Protected Instance Methods

nilthenzero(value) click to toggle source
# File lib/openehr/assumed_library_types.rb, line 189
def nilthenzero(value)
  return value ? value : 0
end