Sha256: 24c40ce3f2f93c9b08003ec7833f75b2c7cf122a2796362fd0096750d8e21e5c
Contents?: true
Size: 532 Bytes
Versions: 344
Compression:
Stored size: 532 Bytes
Contents
from calendar import Calendar def meetup_day(year, month, day_of_the_week, which): candidates = [date for date in Calendar().itermonthdates(year, month) if date.month == month if date.strftime('%A') == day_of_the_week] return _choice(which)(candidates) def _choice(which): if which == 'teenth': return lambda dates: next(d for d in dates if 13 <= d.day <= 19) ix = -1 if (which == 'last') else (int(which[0]) - 1) return lambda dates: dates[ix]
Version data entries
344 entries across 344 versions & 1 rubygems