advent calendar
require 'date'
def advent_calendar(date=DateTime.now)
christmas = DateTime.new(date.year, 12, 25)
christmas = DateTime.new(date.year+1, 12, 25) if date > christmas
difference = (christmas-date).to_i
if difference == 0
puts "Today is Christmas."
else
puts "Only #{difference} day#{"s" unless difference==1} until Christmas."
end
end
advent_calendar(DateTime.new(2006, 12, 24))
Related examples in the same category