アーカイブされた日付関数

この説明は、2018 年 11月より前にサーバーで作成したルールをお持ちの (server4.1.5) 方に向けたものです。クラウドを使用している場合は該当しないため。これを読む代わりにお茶と食後のチョコレートでもお楽しみください。

日付の関数と属性は、日付参照セクションにあります。

警告

次の構文は引き続き機能しますが、新しい日付構文を使用することを強くお勧めします。簡単に使用できるだけでなく、より強力で多くのバグが修正されています。

Automation for Jira では、スマート値、created、updated、duedate、resolutiondate をサポートするフィールドや、日付ピッカー カスタム フィールド内の日付を操作してフォーマットできます (例: {{issue.MyDateFieldName}}または{{issue.customfield_12356}})

日付をフォーマットする

日付の形式は、次の 2 つの方法で指定可能です。

フォーマットの指定

// To format a date field value
{{#issue.resolutiondate}}longDateTime{{/}}
{{#issue.MyDateFieldName}}longDateTime{{/}}

// When no other fields are specified, you can include the format
{{#now}}longDateTime{{/}}
 
// When you specify timezone or a function to manipulate the date you need
// to explicitly label the format and include the value in double quotes.
{{#now}}format="longDateTime",zone=Australia/Sydney{{/}}

ビルトインのフォーマットが多数あるうえに、独自のフォーマットも指定できます。

形式1979 年 11 月 1 日、木曜日、6:23:12 AM EST注意
初期設定 (指定なし)1979 年 11 月 1 日、6:23:12 AMフォーマットが指定されていない場合、初期設定は mediumDateTime です。これは、一部のフィールドの入力として使用すると機能しない可能性があります
toMillis310303392034これはエポックからの経過時間 (ミリ秒) です。
toSeconds310303392これはエポックからの経過時間 (秒) です。
toMinutes5171723これはエポックからの経過時間 (分) です。
toHours86195これはエポックからの経過時間 (時間) です。
toDays3591これはエポックからの経過日数です。

タイム ゾーン

初期設定では、日付をタイム ゾーン「UTC」で表示します。これは OnDemand/Cloud 用の Jira サーバーのタイム ゾーンであり、スケジュールされたトリガーの割り当て時に使用する初期設定のタイムゾーンです。

別のタイムゾーンを指定するには、パラメーターを追加する必要があります。

// Prints the time in Sydney when the issue was created.
{{#issue.created}}zone=Australia/Sydney{{/}}

タイムゾーンは Joda のドキュメントに記載されています。

ユーザーのタイムゾーンを指定する

// Prints the time in the reporters time zone.
{{#issue.created}}zone={{reporter.timeZone}}{{/}}

言語 (ロケール)

初期設定では、日付は英語です。別のロケールを指定するには、パラメーターを指定します。

// Prints the time in Sydney when the issue was created.
{{#issue.created}}locale=ru_RU{{/}}

利用可能なロケールは Java のドキュメントに記載されています

日付の操作

日付の一部を設定するか、そこから値を加算/減算することで、日付を操作します。

// Adds 7 days to the current time
{{#now}}func=plusDays(7){{/now}}
 
// You can chain functions.
// Sets the day to the first of November
{{#issue.created}}func=withDayOfMonth(1).withMonthOfYear(11){{/}}

営業日の計算

営業日を操作するために 2 つの関数が組み込まれています。現在の日付からプラス/マイナスの営業日を指定するか、現在の日付に最も近い営業日を見つけられます。

// The next business day
{{#now}}func=toBusinessDay(){{/}}
// The next business day after 3 days
{{#now}}func=plusDays(3).toBusinessDay(){{/}}
// The previous business day
{{#now}}func=toBusinessDayBackwards(){{/}}

// Adds 6 business days to today
{{#now}}func=plusBusinessDays(6){{/}}

// The number of business days between when the issue was created and today
{{#now}}func=businessDaysBetween({{issue.created}}), format="toDays"{{/}}

2 つの日付の差異を計算する

「toSecond」形式と「minusSeconds」関数によって、ある日付をもう一方の日付から減算します。次に、秒数、分数、時間数、または日数を表示する形式のいずれかを使用します。また、より簡単な構文を持つショートカット メソッド daysBetween もあります。

// The number of hours since an issue was created
{{#now}}func=minusSeconds({{#issue.created}}toSeconds{{/}}), format="toHours"{{/}}

// The number of days between two dates
{{#now}}func=daysBetween({{issue.created}}), format="toDays"{{/}}

// May 1st this year
{{#now}}func=withDayOfMonth(1).withMonthOfYear(5){{/}}

// May 1st next year
{{#now}}func=withDayOfMonth(1).withMonthOfYear(5).plusYears(1){{/}}

// Last day of May
{{#now}}func=withDayOfMonth(1).withMonthOfYear(6).minusDays(1){{/}}

// First business day in May
{{#now}}func=withDayOfMonth(1).withMonthOfYear(5).toBusinessDay(){{/}}

// Last business day in May
{{#now}}func=withDayOfMonth(1).withMonthOfYear(6).minusDays(1)
.toBusinessDayBackwards(){{/}}
最終更新日: 2021 年 10 月 26 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.