Can NAnt <tstamp> format the day of the week as letters like in the Java SimpleDateFormat "E" pattern?

I have searched SO and as far as I can tell this hasn't been asked yet.

I would like to do this in NAnt:

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

      

hoping to get a result like: "Tue May 15, 09:05"

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

Date and time patterns are defined in the Java SimpleDateFormat class .

The SimpleDateFormat doc shows:

E Day of the week Text Tuesday; W

This is why I wrote my template (above) in NAnt. Unfortunately, I got the output: "EEE May 6, 12:27 pm", so it looks like E is not supported.

My workaround is to examine ${datetime::get-day-of-week(datetime::now())}

and set a custom 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 ifs make a lot of mess.


Is there a template that will do what I want?

+1


a source to share


2 answers


This worked for me ...

<tstamp>
    <format property="build.date" pattern="E MMM dd HH:mm:ss z yyyy"/>
</tstamp>

      



and produced ...

build.date=Mon Mar 14 11:27:08 PDT 2011

      

+1


a source


dddd MMM dd, HH: mm



+1


a source







All Articles