Hi,
-----Original Message-----
From: T E Schmitz [mailto:[EMAIL PROTECTED]
Sent: Thursday, January 04, 2007 11:32 PM
To: [email protected]
Subject: extract file date in a given format
/*
Also: could I combine the two scripts and return 2 properties if format
is specified?
*/
i also used javascript a lot, but lately i switched over to (j)ruby
quick hack, something like =
<scriptdef name="filedate" language="ruby">
<attribute name="file"/>
<attribute name="property1"/>
<attribute name="property2"/>
<![CDATA[
stat=File.stat($attributes.get('file'))
$project.setProperty($attributes.get('property1'),stat.mtime.strftime('%
d.%m.%Y'))
$project.setProperty($attributes.get('property2'),stat.mtime.strftime('%
c'))
]]>
</scriptdef>
<filedate file="C:/ruby/LICENSE.txt" property1="mydate"
property2="localdate"/>
<echo>
$${mydate} == ${mydate}
$${localdate} == ${localdate}
</echo>
gives =
[echo] ${mydate} == 03.05.2006
[echo] ${localdate} == Wed May 03 04:29:10 2006
you may change the format of the output via strftime and several
parameter,
f.e %c means preferred local date/time representation
see =
http://www.ruby.ch/ProgrammingRuby/htmlC/ref_c_time.html#strftime
you need bsf.jar (i think you're already have this when using
javascript)
and jruby.jar in ant's classpath for that <scriptdef>, just put
these jar's in %ANT_HOME%/lib and you're done
Regards, Gilbert
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]