tags:

views:

336

answers:

1

I searched SO and as far as I can tell, this hasn't already been asked.

I'd like to do this in NAnt:

<tstamp property="Now" pattern="EEE MMM dd, HH:mm"/>

in hopes of getting a result like: "Tue May 15, 09:05"

The doc for NAnt doesn't explicitly give a list of allowed pattern letters. I thought that it might work the way it does in Ant, so I checked the doc for Ant which says:

The date/time patterns are as defined in the Java SimpleDateFormat class.

The SimpleDateFormat doc shows:

E Day in week Text Tuesday; Tue

Which is why I wrote my pattern (above) in NAnt. Unfortunately, the output I got is: "EEE May 6, 12:27", so it looks like E isn't supported.

My workaround is to examine ${datetime::get-day-of-week(datetime::now())} and set my own dayofweektext property with a bunch of ifs, ala:

<if test="${datetime::get-day-of-week(datetime::now()) == '0'}">
    <property name = "dayofweektext" value = "Sun"/>
</if>

and then use this:

<tstamp property="Now" pattern="${dayofweektext} MMM dd, HH:mm" />

but all the ifs make for a lot of clutter.


Is there a pattern that will do what I want?

A: 

dddd MMM dd, HH:mm

copolii