Created
December 1, 2011 19:23
-
-
Save havenwood/1419161 to your computer and use it in GitHub Desktop.
Yesterday, Today, Tomorrow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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