module OpenEHR::AssumedLibraryTypes::TimeDefinitions
Constants
- DAYS_IN_LEAP_YEAR
- 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/open_ehr/assumed_library_types.rb, line 150 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/open_ehr/assumed_library_types.rb, line 160 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/open_ehr/assumed_library_types.rb, line 173 def self.valid_minute?(mi) mi >= 0 and mi < MINUTES_IN_HOUR end
valid_month?(mo)
click to toggle source
# File lib/open_ehr/assumed_library_types.rb, line 181 def self.valid_month?(mo) mo >= 1 and mo <= MONTH_IN_YEAR end
valid_second?(s)
click to toggle source
# File lib/open_ehr/assumed_library_types.rb, line 177 def self.valid_second?(s) s >= 0 and s < SECONDS_IN_MINUTE end
valid_year?(year)
click to toggle source
# File lib/open_ehr/assumed_library_types.rb, line 146 def self.valid_year?(year) return !year.nil? && year >= 0 end
Protected Instance Methods
nilthenzero(value)
click to toggle source
# File lib/open_ehr/assumed_library_types.rb, line 186 def nilthenzero(value) return value ? value : 0 end