Hello Ann,

According to the NAnt document, for most of the DateTime functions, the output 
is typically "formatted with the DateTimeFormatInfo for the invariant culture." 
I think the proper fix is to allow an IFormatProvider (ie DatetimeFormatInfo) 
to be passed as an (optional) argument to the NAnt DateTime functions. Similar 
to DateTime.ToString(IFormatProvider) in the .NET Framework SDK:
http://msdn.microsoft.com/en-us/library/ht77y576.aspx

As a temporarily workaround, could you use NAnt's string::pad-left() function 
instead? As an example:

Build file:
<?xml version="1.0" ?>
<project name="test">
  <echo message="month: ${datetime::get-month(datetime::now())}" />

  <!-- left pad with "0" if length is less than 2 -->
  <echo message="month: 
${string::pad-left(datetime::get-month(datetime::now()), 2, 0)}" /> 
</project>

Output:
     [echo] month: 3
     [echo] month: 03

I admit it's a bit of a hack, but it get's the job done (until a proper fix is 
implemented). I hope this helps.

Regards,
Charles

--- On Mon, 3/29/10, Ann Chaplinskaya <ann.ch...@gmail.com> wrote:

From: Ann Chaplinskaya <ann.ch...@gmail.com>
Subject: [NAnt-users] Date/Time Functions
To: nant-users@lists.sourceforge.net
Received: Monday, March 29, 2010, 3:01 AM




Hello 
all,
 
In my Nant script I 
use datetime::get-month, datetime::get-hour functions and others DateTime 
functions, but the dates  are represented in  yyyy/m/d/ and  h/m/s format (eg 
2010_3_2,  3-2-6), but I 
need  yyyy/mm/dd , hh/mm/ss ,  like this  2010_03_02  03-02-06.
 
Can anybody help? 
What should I change? 
 
Regards,
Anna
 

-----Inline Attachment Follows-----

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
-----Inline Attachment Follows-----

_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users



      __________________________________________________________________
Looking for the perfect gift? Give the gift of Flickr! 

http://www.flickr.com/gift/

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to