| “Strategies in (*)ability” | [iDareMedia] [JWare] [PET] [CI-Dashboard] |
The datetime value uris let you insert formatted date time strings as attribute values without having to create project properties. This is a small set of uris where the (predefined) output format is determined by the uri’s scheme name; you can also supply your own format and timestamp using the uri’s query string. These uris are most useful as a substitute for <tstamp> in macrodefs that are called repeatedly from the same project. You must explicitly install this value URI handler; read the Examples section to see how this is done.
The general form of the URI is: $formatname:[now|timestamp][?format-string] where formatname is the is one of the predefined datetime formats like “longtime”. The incoming timestamp is either the symbolic name “now” for the current time or a millisecond timestamp value. You can also provide a custom format format-string as a query parameter after the '?' mark; this format string is passed verbatim to the SimpleDateFormat Java utility class.
Below is a table of the predefined format names and example generated values. To force the handler to use your own format string use any name that is not in this list; for example, you could use the scheme $tstamp: for your custom format strings.
| Scheme | Example |
| $longdatetime: | |
| $longtime: | |
| $longdate: | |
| $gmtdatetime: | |
| $gmtdate: | |
| $gmttime: | |
| $shortdatetime: | |
| $shorttime: | |
| $shortdate: | |
| $datetime: | |
| $time: | |
| $date: | |
| $duration: | |
| $changelogdate: | |
| $cvsdate: | |
| $svndate: |
1) The following snippet declares the default scheme names for the datetime uri handler. The snippet has been abbreviated for space considerations. This is usually done by an “init” target or at the project’s top level.
<manageuris action="install">
<parameter name="longdatetime"
value="com.idaremedia.antx.valueuri.datetime.DateTimeValueURIHandler"/>
<parameter name="longdate"
value="com.idaremedia.antx.valueuri.datetime.DateTimeValueURIHandler"/>
<parameter name="longtime"
value="com.idaremedia.antx.valueuri.datetime.DateTimeValueURIHandler"/>
...
<parameter name="cvschangelog"
value="com.idaremedia.antx.valueuri.datetime.DateTimeValueURIHandler"/>
</manageuris>
2) The following snippet declares its own scheme name “tstamp” for custom datetime format strings. Any script that includes this declaration can generate tstamps strings from a uri like the shown writefinished macro.
<manageuris action="install">
<parameter name="tstamp"
value="com.idaremedia.antx.valueuri.datetime.DateTimeValueURIHandler"/>
</manageuris>
...
<macrodef name="writefinished">
<attribute name="op"/>
<attribute name="started"/>
<sequential>
<assert varset="@{started}" msg="starttime '@{started}' exists"/>
<assign var="_whenfinished" op="-now" fromvariable="@{started}"/>
<echo file="${logs}/@{op}.last">
End Hour: ${$tstamp:now?hh 'o''clock' a, zzzz}
Duration: ${$var:_whenfinished|$duration:}
</echo>
</sequential>
</macrodef>