/ Published in: Python

URL: http://mail.python.org/pipermail/python-list/2005-July/333218.html
like PHP's 'jS'
Expand |
Embed | Plain Text
if 4 <= day <= 20 or 24 <= day <= 30: suffix = "th" else: suffix = ["st", "nd", "rd"][day % 10 - 1]
Comments

You need to login to post a comment.
Handy with a Mako filter like this:
`<%! from time import strftime as time %> It is the ${"%d of %B" | time}
<%doc> In [1]: print app.get('/a') Response: 200 content-type: text/html; charset=utf-8 cache-control: no-cache It is the 05 of August `
http://pylonshq.com/pasties/395
Argh. Code in Markdown is annoying.
http://pylonshq.com/pasties/395