Skip to content

Instantly share code, notes, and snippets.

@havenwood
Created December 1, 2011 19:23
Show Gist options
  • Select an option

  • Save havenwood/1419161 to your computer and use it in GitHub Desktop.

Select an option

Save havenwood/1419161 to your computer and use it in GitHub Desktop.
Yesterday, Today, Tomorrow
#!/usr/bin/env ruby
class Time
WEEKDAYS = %w[ Sunday Monday Tuesday Wednesday Thursday Friday Saturday ]
def day_before_yesterday
xday -2
end
def yesterday
xday -1
end
def today
xday 0
end
def tomorrow
xday 1
end
def day_after_tomorrow
xday 2
end
private
def xday offset
WEEKDAYS[(Time.now.wday + offset) % 7]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment