Last active
September 4, 2015 16:32
-
-
Save soulcutter/72f6843ed6785c4dd582 to your computer and use it in GitHub Desktop.
Each day
This file contains 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
def days(range) | |
Enumerator.new do |yielder| | |
now = range.begin | |
begin | |
yielder << now if now <= range.end | |
end while (now = now + 1.day) <= range.end | |
end | |
end | |
days((Time.now - 3.days)..(Time.now)).each { |day| puts day } | |
# 09-02-2015 12:04:55 | |
# 09-03-2015 12:04:55 | |
# 09-04-2015 12:04:55 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment