Programmer’s Day! When?2007-09-11 at 14:35 | Posted in devel, it, lang:en, life | Leave a comment
We all (hopefully) know that the programmer’s day is the 256th day of the year, i. e. 2007-256 in ISO 8601. But when should we celebrate it this year? This piece of code that uses the Python’s standard library (batteries included) will answer the question:
def pday(year): return yday(year, 256) def yday(year, day): import datetime, time t = time.strptime("%d-%03d" % (year, day), "%Y-%j") return datetime.datetime(*t[0:6])
pday(2007) is 2007-09-13.