You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

tstamp.html 6.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <!DOCTYPE html>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. https://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. -->
  16. <html lang="en">
  17. <head>
  18. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  19. <title>TStamp Task</title>
  20. </head>
  21. <body>
  22. <h2 id="tstamp">Tstamp</h2>
  23. <h3>Description</h3>
  24. <p>Sets the <code>DSTAMP</code>, <code>TSTAMP</code>, and <code>TODAY</code> properties in the
  25. current project. By default, the <code>DSTAMP</code> property is in the
  26. format <q>yyyyMMdd</q>, <code>TSTAMP</code> is in the format <q>hhmm</q>, and <code>TODAY</code> is
  27. in the format <q>MMMM dd yyyy</q>. Use the nested <code>&lt;format&gt;</code> element to specify a
  28. different format.</p>
  29. <p>These properties can be used in the build file, for instance, to create timestamped filenames, or
  30. used to replace placeholder tags inside documents to indicate, for example, the release date. The
  31. best place for this task is probably in an initialization target.</p>
  32. <p><em>Since Ant 1.10.2</em> the magic property <code>ant.tstamp.now</code> can be used to specify a
  33. fixed date value in order to create reproducible builds. Its value must be a number and is
  34. interpreted as seconds since the epoch (midnight 1970-01-01). With <code>ant.tstamp.now.iso</code>
  35. you could also specify that value in ISO-8601 format (<code>1972-04-17T08:07:00Z</code>). If you
  36. specify a value in an invalid format an INFO message will be logged and the value will be
  37. ignored.</p>
  38. <p>
  39. <em>Since Ant 1.10.8</em> the <code>SOURCE_DATE_EPOCH</code> environment variable value (if set)
  40. will be honoured for <a href="https://reproducible-builds.org/specs/source-date-epoch/#idm55">reproducible builds</a>.
  41. Ant will log a DEBUG message if an invalid value (value that cannot be parsed to an integer), is specified
  42. for that environment variable and will instead use the "current" date.
  43. </p>
  44. <h3>Parameters</h3>
  45. <table class="attr">
  46. <tr>
  47. <th scope="col">Attribute</th>
  48. <th scope="col">Description</th>
  49. <th scope="col">Required</th>
  50. </tr>
  51. <tr>
  52. <td>prefix</td>
  53. <td>Prefix used for all properties set.</td>
  54. <td>No; default is no prefix</td>
  55. </tr>
  56. </table>
  57. <h3>Parameters specified as nested elements</h3>
  58. <p>The task supports a <code>&lt;format&gt;</code> nested element that allows a property to be set
  59. to the current date and time in a given format. The date/time patterns are as defined in the
  60. Java <a href="https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html"
  61. target="_top">SimpleDateFormat</a> class. The format element also allows offsets to be applied to
  62. the time to generate different time values.</p>
  63. <table class="attr">
  64. <tr>
  65. <th scope="col">Attribute</th>
  66. <th scope="col">Description</th>
  67. <th scope="col">Required</th>
  68. </tr>
  69. <tr>
  70. <td>property</td>
  71. <td>The property to receive the date/time string in the given pattern.</td>
  72. <td>Yes</td>
  73. </tr>
  74. <tr>
  75. <td>pattern</td>
  76. <td>The date/time pattern to be used. The values are as defined by the Java SimpleDateFormat
  77. class.</td>
  78. <td>Yes</td>
  79. </tr>
  80. <tr>
  81. <td>timezone</td>
  82. <td>The timezone to use for displaying time. The values are as defined by the
  83. Java <a href="https://docs.oracle.com/javase/8/docs/api/java/util/TimeZone.html"
  84. target="_top">TimeZone</a> class.</td>
  85. <td>No</td>
  86. </tr>
  87. <tr>
  88. <td>offset</td>
  89. <td>The numeric offset to the current time</td>
  90. <td>No</td>
  91. </tr>
  92. <tr>
  93. <td>unit</td>
  94. <td>The unit of the offset to be applied to the current time. Valid values are
  95. <ul>
  96. <li><q>millisecond</q></li>
  97. <li><q>second</q></li>
  98. <li><q>minute</q></li>
  99. <li><q>hour</q></li>
  100. <li><q>day</q></li>
  101. <li><q>week</q></li>
  102. <li><q>month</q></li>
  103. <li><q>year</q></li>
  104. </ul>
  105. </td>
  106. <td>No</td>
  107. </tr>
  108. <tr>
  109. <td>locale</td>
  110. <td>The locale used to create date/time string. The general form is <q>language[, country[,
  111. variant]]</q> (either <q>variant</q> or both <q>variant</q> and <q>country</q> may be
  112. omitted). For more information please refer to documentation for
  113. the <a href="https://docs.oracle.com/javase/8/docs/api/java/util/Locale.html"
  114. target="_top">Locale</a> class.</td>
  115. <td>No</td>
  116. </tr>
  117. </table>
  118. <h3>Examples</h3>
  119. <p>Set the standard <code>DSTAMP</code>, <code>TSTAMP</code>, and <code>TODAY</code> properties
  120. according to the default formats.</p>
  121. <pre>&lt;tstamp/&gt;</pre>
  122. <p>Set the standard properties as well as the property <code>TODAY_UK</code> with the date/time
  123. pattern <q>d-MMMM-yyyy</q> using English locale (eg. 21-May-2001).</p>
  124. <pre>
  125. &lt;tstamp&gt;
  126. &lt;format property=&quot;TODAY_GB&quot; pattern=&quot;d-MMMM-yyyy&quot; locale=&quot;en,GB&quot;/&gt;
  127. &lt;/tstamp&gt;</pre>
  128. <p>Create a timestamp, in the property <code>touch.time</code>, 5 hours before the current time. The
  129. format in this example is suitable for use with the <code>&lt;touch&gt;</code> task. The standard
  130. properties are set also.</p>
  131. <pre>
  132. &lt;tstamp&gt;
  133. &lt;format property=&quot;touch.time&quot; pattern=&quot;MM/dd/yyyy hh:mm aa&quot;
  134. offset=&quot;-5&quot; unit=&quot;hour&quot;/&gt;
  135. &lt;/tstamp&gt;</pre>
  136. <p>Set three properties with the standard formats, prefixed
  137. with <q>start.</q>: <code>start.DSTAMP</code>, <code>start.TSTAMP</code>,
  138. and <code>start.TODAY</code>.</p>
  139. <pre>&lt;tstamp prefix="start"/&gt;</pre>
  140. </body>
  141. </html>