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])

So, pday(2007) is 2007-09-13.

Leave a Comment »

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at
Entries and comments feeds.

%d bloggers like this: