moduleChronicclassDateYEAR_MONTHS=12MONTH_DAYS=[nil,31,28,31,30,31,30,31,31,30,31,30,31]MONTH_DAYS_LEAP=[nil,31,29,31,30,31,30,31,31,30,31,30,31]YEAR_SECONDS=31_536_000# 365 * 24 * 60 * 60SEASON_SECONDS=7_862_400# 91 * 24 * 60 * 60MONTH_SECONDS=2_592_000# 30 * 24 * 60 * 60FORTNIGHT_SECONDS=1_209_600# 14 * 24 * 60 * 60WEEK_SECONDS=604_800# 7 * 24 * 60 * 60WEEKEND_SECONDS=172_800# 2 * 24 * 60 * 60DAY_SECONDS=86_400# 24 * 60 * 60MONTHS={:january=>1,:february=>2,:march=>3,:april=>4,:may=>5,:june=>6,:july=>7,:august=>8,:september=>9,:october=>10,:november=>11,:december=>12}DAYS={:sunday=>0,:monday=>1,:tuesday=>2,:wednesday=>3,:thursday=>4,:friday=>5,:saturday=>6}# Checks if given number could be daydefself.could_be_day?(day)day>=1&&day<=31end# Checks if given number could be monthdefself.could_be_month?(month)month>=1&&month<=12end# Checks if given number could be yeardefself.could_be_year?(year)year>=1&&year<=9999end# Build a year from a 2 digit suffix.## year - The two digit Integer year to build from.# bias - The Integer amount of future years to bias.## Examples:## make_year(96, 50) #=> 1996# make_year(79, 20) #=> 2079# make_year(00, 50) #=> 2000## Returns The Integer 4 digit year.defself.make_year(year,bias)returnyearifyear.to_s.size>2start_year=Chronic.time_class.now.year-biascentury=(start_year/100)*100full_year=century+yearfull_year+=100iffull_year<start_yearfull_yearenddefself.month_overflow?(year,month,day)if::Date.leap?(year)day>Date::MONTH_DAYS_LEAP[month]elseday>Date::MONTH_DAYS[month]endendendend