Skip to content

Instantly share code, notes, and snippets.

@dhwthompson
Last active December 16, 2015 03:49
Show Gist options
  • Save dhwthompson/5372607 to your computer and use it in GitHub Desktop.
Save dhwthompson/5372607 to your computer and use it in GitHub Desktop.
A script to list upcoming Fridays 12th.
#!/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()
#!/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