Last active
December 16, 2015 03:49
-
-
Save dhwthompson/5372607 to your computer and use it in GitHub Desktop.
A script to list upcoming Fridays 12th.
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
#!/usr/bin/env python | |
from datetime import date, timedelta | |
def fridays_12th(): | |
d = date.today() | |
while True: | |
if d.weekday() == 4 and d.day == 12: | |
yield d | |
d += timedelta(days=1) | |
g = fridays_12th() | |
for _ in range(5): | |
print g.next() |
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
#!/usr/bin/env ruby | |
require 'date' | |
e = Enumerator.new do |yielder| | |
d = Date.today | |
loop do | |
yielder << d if d.day == 12 && d.friday? | |
d = d.next | |
end | |
end | |
e.take(5).each do |d| puts d end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment