Module: OpenEHR::AssumedLibraryTypes::ISO8601DateModule
Overview
Constant Summary
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
valid_day?, valid_hour?, valid_minute?, valid_month?, valid_second?, valid_year?
Instance Attribute Details
#day ⇒ Object
Returns the value of attribute day.
226
227
228
|
# File 'lib/openehr/assumed_library_types.rb', line 226
def day
@day
end
|
#month ⇒ Object
Returns the value of attribute month.
226
227
228
|
# File 'lib/openehr/assumed_library_types.rb', line 226
def month
@month
end
|
#year ⇒ Object
Returns the value of attribute year.
226
227
228
|
# File 'lib/openehr/assumed_library_types.rb', line 226
def year
@year
end
|
Instance Method Details
#as_string ⇒ Object
246
247
248
249
250
251
252
253
254
|
# File 'lib/openehr/assumed_library_types.rb', line 246
def as_string
if (!@year.nil? and !@month.nil? and !@day.nil?)
Date.new(@year, @month, @day).to_s
elsif (!@year.nil? and !@month.nil? and @day.nil?)
Date.new(@year, @month).to_s[0,7]
elsif (!@year.nil? and @month.nil? and @day.nil?)
Date.new(@year).to_s[0,4]
end
end
|
#day_unknown? ⇒ Boolean
267
268
269
|
# File 'lib/openehr/assumed_library_types.rb', line 267
def day_unknown?
@day.nil?
end
|
#is_extended? ⇒ Boolean
271
272
273
|
# File 'lib/openehr/assumed_library_types.rb', line 271
def is_extended?
true
end
|
#is_partial? ⇒ Boolean
275
276
277
|
# File 'lib/openehr/assumed_library_types.rb', line 275
def is_partial?
month_unknown? or day_unknown?
end
|
#leapyear?(year) ⇒ Boolean
279
280
281
282
283
284
285
|
# File 'lib/openehr/assumed_library_types.rb', line 279
def leapyear?(year)
case
when (year % 400) == 0 then true
when (year % 100) == 0 then false
else year % 4 == 0
end
end
|
#month_unknown? ⇒ Boolean
263
264
265
|
# File 'lib/openehr/assumed_library_types.rb', line 263
def month_unknown?
@month.nil?
end
|