views:

63

answers:

2

Seems like it should be simple enough but it's driving me up the wall. I've looked at the python date formatting strings and it still doesn't make too much sense.

Here's what I'm trying to do: <Full day>, <Day of month><Ordinal> <Month>

Where <Ordinal> is st, nd, rd, th, etc depending on the day.

+1  A: 

Just found the answer in the docs. God knows why they're not linked to from every reference to date formatting.

{{e.when|date:"l, jS F"}}
Oli
Pretty sure you want `{{ e.when|date:"l, jS F" }}` instead.
Jordan Reiter
Aha. Django's date formatting differs from Python's. Do you mind editing your question to say that you are looking for something Django specific?
Manoj Govindan
+2  A: 

Update 2: Looks like OP found this useful after all :)

Update: Never mind. The OP was looking for Django date formatting, not Python.

AFAIK there is no built in format specifier for the ordinal. The others are easy:

my_date.strftime('%A, %d %B')

I found this solution on the web:

if 4 <= day <= 20 or 24 <= day <= 30:
    suffix = "th"
else:
    suffix = ["st", "nd", "rd"][day % 10 - 1]
Manoj Govindan
This is still very much relevant to my interests. I do process dates behind the scenes (in Python) too.
Oli