日付フォーマッタ

Version 23.4.8841


日付フォーマッタ


Common Date Formatters

The following formatters are the most common date formatters. An example for each formatter is provided for reference.

Additional examples of date format syntax are provided in サンプル日付フォーマット.

now([outputformat])

Returns the current system datetime according to the specified outputformat (default format is: yyyy-MM-dd’T’hh:mm:sszzz).

This formatter is unusual in that it does not modify the input attribute (variable), so no such input attribute is required.

Example

<arc:set attr="timestamp" value="[now()]" />

todate([outputformat][, inputformat][, strictInputFormat])

Formats the input attribute as a date in the format specified by outputformat (the default output format is: yyyy-MM-dd’T’hh:mm:sszzz). For examples of date formats and how they are expressed, see サンプル日付フォーマット.

The formatter attempts to auto-detect the format of the input value, but you can specify the inputformat parameter if the formatter is unable to determine the input format.

Use the strictInputFormat argument to check whether the incoming date value matches the input format: if it does not the task throws an error instead of converting the date to a standard date format. The default is not to check. To force the check, add true to the formatter.

Example

<arc:set attr="simpleDate" value="01-30-2020" />
<arc:set attr="reformattedDate" value="[simpleDate | todate('yyyyMMdd', 'dd-MM-yyyy')]" />

dateadd(intervaltype, value[, outputformat][, inputformat])

Adds a specified amount of time to the input date and returns the result. The intervaltype parameter specifies the unit of time to add (e.g. ‘year’, ‘month’, ‘day’, ‘hour’, ‘minute’, ‘second’, ‘millisecond’) and the value parameter specifies how many of these units to add.

The formatter will attempt to auto-detect the format of the input value, but the inputformat parameter can be specified if the formatter is otherwise unable to determine the datetime format of the input attribute. The result will be returned in the format specified by outputformat (default output format is: yyyy-MM-dd’T’hh:mm:sszzz).

Example

<arc:set attr="shipdate" value="2020-03-15" />
<arc:set attr="estmArrivalDate" value="[shipdate | dateadd('day', 2)]" />

More Date Formatters

Below is the list of less-common formatters not included in the previous section.

compare([value][, inputformat])

属性値とパラメータ値によって表される日付の相対値を示す符号付き数値を返します。

  • value:属性値と比較される日付の文字列表現(オプション)。デフォルトはnow です。
  • inputformat:入力フォーマット指定子(オプション)。デフォルトは自動検出されます。

date([outputformat])

Note:This formatter is an alias for the now() formatter described in the previous section.

現在のシステム日時を、パラメータで指定されている場合は、指定された形式で返します。

  • outputformat:フォーマット指定子(オプション)。有効な指定子は、d(短い形式の日)、D(長い形式の日)、f(長い形式の日/短い形式の時間 )、F(長い形式の日/時間)、g(標準の短い形式の日/時)、G(標準の短い形式の日/長い形式の時間)、r またはR (RFC1123 形式)、s(ソート可能な形式の日/時)、t(短い形式の時間)、T(長い形式の時間)、file(Windows ファイル時間)、MM/dd/yy などです。

datediff([interval][, value][, inputformat])

現在と2つ目のパラメータで指定した日付との差を(1つ目のパラメータで指定した単位で)返します。

  • interval:結果を表示する間隔(オプション)。day、hour、minute、second、またはmillisecond を指定します。
  • value:属性値と比較する日付の文字列表現(オプション)。デフォルトはnow です。
  • inputformat:入力フォーマット指定子(オプション)。デフォルトは自動検出されます。

day([inputformat])

属性値で表される日付の、1から31までの値で表される日の部分を返します。

  • inputformat:入力フォーマット指定子(オプション)。デフォルトは自動検出されます。

dayofweek([inputformat])

属性値で表される日付の曜日を返します。

  • inputformat:入力フォーマット指定子(オプション)。デフォルトは自動検出されます。

dayofyear([inputformat])

属性値で表される日付の、1から366までの値で表される年日を返します。

  • inputformat:入力フォーマット指定子(オプション)。デフォルトは自動検出されます。

filetimenow()

現在のシステムファイルの時刻の日時を返します。

fromfiletime([outputformat])

有効なファイル時刻を、パラメーターが指定されている場合は、パラメーターで指定された形式の有効な日時値に変換します。

  • outputformat:出力フォーマット指定子(オプション)。有効な指定子は、d(短い形式の日)、D(長い形式の日)、f(長い形式の日/短い形式の時間 )、F(長い形式の日/時間)、g(標準の短い形式の日/時)、G(標準の短い形式の日/長い形式の時間)、r またはR (RFC1123 形式)、s(ソート可能な形式の日/時)、t(短い形式の時間)、T(長い形式の時間)、file(Windows ファイル時間)、MM/dd/yy などです。

isleap([ifleap][, ifnotleap])

属性値で表される4桁の年がうるう年であればtrue(またはifleap)、それ以外の場合はfalse(またはifnotleap)を返します。

  • ifleap:属性値がうるう年の場合に返される値(オプション)。
  • ifnotleap:属性値がうるう年でない場合に返される値(オプション)。

month([inputformat])

属性値で表される日付の、1から12までの値で表される月の部分を返します。

  • inputformat:入力フォーマット指定子(オプション)。デフォルトは自動検出されます。

tofiletime([inputformat])

有効な日時を有効なファイル時刻値に変換します。

  • inputformat:入力フォーマット指定子(オプション)。デフォルトは自動検出されます。

toutc([outputformat][, inputformat])

属性値で指定された日付をUTC に変換し、outputformat パラメータが指定されている場合はそれに合わせてフォーマットして返します。

  • outputformat:フォーマット指定子(オプション)。有効な指定子は、d(短い形式の日)、D(長い形式の日)、f(長い形式の日/短い形式の時間 )、F(長い形式の日/時間)、g(標準の短い形式の日/時)、G(標準の短い形式の日/長い形式の時間)、r またはR (RFC1123 形式)、s(ソート可能な形式の日/時)、t(短い形式の時間)、T(長い形式の時間)、file(Windows ファイル時間)、MM/dd/yy などです。

utcnow([outputformat])

現在のシステムのUTC 日時を返します。

  • outputformat:フォーマット指定子(オプション)。有効な指定子は、d(短い形式の日)、D(長い形式の日)、f(長い形式の日/短い形式の時間 )、F(長い形式の日/時間)、g(標準の短い形式の日/時)、G(標準の短い形式の日/長い形式の時間)、r またはR (RFC1123 形式)、s(ソート可能な形式の日/時)、t(短い形式の時間)、T(長い形式の時間)、file(Windows ファイル時間)、MM/dd/yy などです。

weekday([inputformat])

曜日を、月曜日が0、日曜日が6の整数値で返します。

  • inputformat:入力フォーマット指定子(オプション)。デフォルトは自動検出されます。

year([inputformat])

属性値で表される日付の年部分を返します。

  • inputformat:入力フォーマット指定子(オプション)。デフォルトは自動検出されます。

サンプル日付フォーマット

以下は、参照用の日付フォーマット文字列のサンプルです。これらを使って、ユースケースに合わせて日付フォーマッタをカスタマイズしてください。各エディションでサポートされている内容に違いがあるため、このセクションではクロスプラットフォーム版.NET 版の両方の結果を記載しています。

次のテーブルの各例では、日付は2024年3月5日を使用します。時刻は、東部標準時間(UTC-5)の午前0時から12時間31分5秒336ミリ秒後です。

日付フォーマット文字列 クロスプラットフォーム版 .NET 版
MM-dd-yy 03-05-24 03-05-24
MM/dd/yyyy HH:mm 03/05/2024 12:31 03/05/2024 12:31
yyyy-MM-dd HH:mm:ss 2024-03-05 12:31:05 2024-03-05 12:31:05
yyyy-MM-dd HH:mm:ss.SSS 2024-03-05 12:31:05.336 .NET には適用されません
yyyy-MM-dd HH:mm:ss.fff 2024-03-05 12:31:05.336 2024-03-05 12:31:05.336
yyyy-MM-dd HH:mm:ss X 2024-03-05 17:31:05 -05 .NET には適用されません
ddd dd MMM yyyy HH:mm:ss zzz Tue 05 Mar 2024 12:31:05 -05:00 Tue 05 Mar 2024 12:31:05 -05:00
ddd dd MMM yyyy HH:mm:ss z Tue 05 Mar 2024 12:31:05 -0500 Tue 05 Mar 2024 12:31:05 -5

リテラル文字を含む日付フォーマット

DateTime 文字列でリテラル(’T’ など)を扱う場合は、フォーマッタの外部で使用される可能性のある引用符に注意してください。例えば、value XML 属性でフォーマッタを使用してArcScript 属性に値を割り当てる場合、文字列の終端が早すぎないように、別の引用符スタイルやエスケープシーケンスを使う必要がある場合があります。

例えば、カスタムスクリプトでアイテムの属性にdatetime 値を作成し、リテラルが必要な場合、開始タグと終了arc:set タグの間に属性の値を定義することができます。value="" は設定されていないことに注意してください。

<arc:set attr="out.data">[_ | now("yyyy-MM-dd'T'HH:mm:ss")]</arc:set>