Formatting a date

How do I format a date in a reference, based on which parts of day/month/year are present? I can't work out how to test on date-part.

Essentially, if the date is just given as 2008 I want "2008". If it's given as "02-2008" then I want "Feb. 2008" and if it's 26-02-2008 then I want 26th Feb 2008, so presumably I need to test on the presence of <date-part name="day"/> and <date-part name="month"/>. I can't work out how to do that test, and I can't find an example that puts more than the year in the reference.

Thanks in advance.
  • edited February 26, 2008
    <date variable="issued">
    <date-part name="day" suffix="th "/>
    <date-part name="month" form="short" suffix=". "/>
    <date-part name="year"/>
    </date>
  • Thanks -- I see what you mean; if the date part isn't there then nothing will appear. The "suffix="th " would be wrong if it's the 21st or 2nd, but I see that there's an "ordinal" attribute that will give the correct behaviour.
Sign In or Register to comment.