Posted By

ches on 08/05/07


Tagged

date python DateTime


Versions (?)

python date suffixes for strftime


 / Published in: Python
 

URL: http://mail.python.org/pipermail/python-list/2005-July/333218.html

like PHP's 'jS'

  1. if 4 <= day <= 20 or 24 <= day <= 30:
  2. suffix = "th"
  3. else:
  4. suffix = ["st", "nd", "rd"][day % 10 - 1]

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: ches on August 7, 2007

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

Posted By: ches on August 7, 2007

Argh. Code in Markdown is annoying.

<%! 
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
</%doc>

http://pylonshq.com/pasties/395

You need to login to post a comment.