日付におけるスマート バリューの使用例
Jira Automation テンプレート ライブラリでスマート バリューを使用する方法をご確認ください。
You can use smart values to manipulate and format created, updated, duedate and resolutiondate dates.
これらの関数はスマート バリューをサポートするフィールド内の日付ピッカー カスタム フィールド ({{issue.MyDateFieldName}}
または {{issue.customfield_12356}}
など) でも使用できます。
View the smart values available to manipulate and format dates.
日付をフォーマットする
Specify the format of a date at the end of the smart value, as shown below. View available date formats.
// using inbuilt formats
{{issue.resolutiondate.asLongDateTime}}
{{issue.MyDateFieldName.longDateTime}}
{{issue.created.jqlDateTime}}
{{issue.created.mediumTime}}
{{issue.Sprint.endDate.jiraDate}} - format the Sprint field's end date into a format suitable to set another field
// Or, you can specify the format
{{issue.dueDate.format("dd/MM/yyyy")}}
{{issue.created.as("dd MMM")}}
ロケール (位置に基づく日付形式)
日付を表示するロケールを指定します (初期設定は「US」ロケール)。
// Prints the issue's created date in French
{{issue.created.withLocale("fr").asLongDateTime}}
// Prints the issue's created date in French Canadian
{{issue.created.locale("fr_CA").longDateTime}}
// Prints the issue's created date in the locale of the reporter
{{issue.created.locale(issue.reporter.locale).longDateTime}}
For a list of locales, refer to the Java documentation.
タイム ゾーン
初期設定では、日付は「UTC」タイムゾーンで表示されます。別のタイムゾーンを指定する方法は以下のとおりです。
// Converts the issue's created time to the new timezone,
// e.g. 10am UTC converts to 8pm AEST
{{issue.created.convertToTimeZone("Australia/Sydney")}}
// Converts the issue's created time to the new timezone and keeps the same
// times/dates. E.g. 10am UTC changes to 10am AEST
{{issue.created.setTimeZone("Australia/Sydney")}}
For a list of timezones, refer to the Java documentation.
ユーザーのタイムゾーンを指定する
// Prints the issue's created time in the reporters timezone.
{{issue.created.convertToTimeZone(issue.reporter.timeZone)}}
日付の操作
日付の一部を設定するか、そこから値を加算または減算することで日付を操作します。
// Add 7 days to the current time
{{now.plusDays(7)}}
// You can also chain functions
// Set the created date to November 1st
{{issue.created.withDayOfMonth(1).withMonth(11)}}
日付属性
日付内の個々の属性 (月など) を取得します。
// Get today's day of the month
{{now.dayOfMonth}}
// Get the day of the week the issue was created
{{issue.created.dayOfWeekName}}
// Get the day name of the week in French
{{issue.created.locale("fr").dayOfWeekName}}
営業日の計算
現在の日付から営業日を増減するか、現在の日付に最も近い営業日を見つけます。営業日は月曜日から金曜日の 9 - 18 時とします。
// The next business day
{{now.toBusinessDay()}}
// The next business day after 3 days
{{now.plusDays(3).toBusinessDay()}}
// The previous business day
{{now.toBusinessDayBackwards()}}
// Adds 6 business days to today
{{now.plusBusinessDays(6)}}
// The first business day of the month
{{now.firstBusinessDayOfMonth}}
// The last business day of the month
{{now.lastBusinessDayOfMonth}}
// The number of business days beeween when the issue was created and today
{{now.diff(issue.created).businessDays}}
2 つの日付の差異を計算する
Uses the diff method to calculate the difference between two dates by passing in another date and then specifying the unit to measure.
// Gets how many hours since an issue was created
{{now.diff(issue.created).hours}}
// Gets the number of days between two dates
{{now.diff(issue.created).days}}
// To show positive dates use the "abs" method
{{now.diff(issue.<date field>).days.abs}}
2 つの日付を比較する
2 つの指定された日付を比較しします。これらのメソッドは、別の日付をパラメーターとして取得します。
// Returns "true"
{{now.isAfter(issue.created)}}
Compare dates using the Advanced compare condition.
テキストを日付に変換する
日付がテキストの場合 (changelog 内など)、日付はテキストとして保存されます。
{{issue.summary.toDate}}
正しいフォーマットの場合、テキストを日付に変換します。パラメーターを追加することで、どのフォーマットから変換するかを指定できます。
以下の例では、テキスト (「2020 02 15」など) を日付オブジェクトに変換します。
{{issue.summary.toDate("yyyy MM dd")}}
テキストを日付オブジェクトに変換した後に、フィールドの変更など、そのオブジェクトをさらに変換する必要がある場合があります (例: 日付の変更をリッスンする場合)。
{{fieldChange.fromString.toDate.plusDays(1).longDate}}
現在の日付/時刻を参照する
現在の日付や時間は、{now} を使用して参照できます。
例
// 1st of May this year
{{now.startOfMonth.withMonth(5)}}
// 1st of May next year
{{now.startOfMonth.withMonth(5).plusYears(1)}}
// last day of May
{{now.withMonth(5).endOfMonth}}
// first business day in May
{{now.withMonth(5).firstBusinessDayOfMonth}}
// last business day in May
{{now.withMonth(5).lastBusinessDayOfMonth}}
この内容はお役に立ちましたか?