Cloud Migration Resources
Planning a Jira Cloud migration? These resources can help you get started:
→ JMWE Cloud features – Review Cloud features and understand key differences between DC and Cloud.
→ Migration support from Appfire – Learn how we can help you migrate smoothly.
duration filter
In the Nunjucks templates of JMWE to create, manipulate and format durations, JMWE uses the duration objects of the Moment.js library. All the functions provided by the library, that are available to your Nunjucks templates through the duration filter, return a Moment.js duration object. A Moment.js duration object is an object that represents the length of time in milliseconds, and can easily be manipulated and formatted for display. Refer to the official documentation for more information about Moment.js.
Duration creation
duration
Description:
Creates a Moment.js duration object from a duration number, or a string representing a duration. This duration object can then be used with the other duration filters. It returns a number representing the specified duration in the specified unit. If not specified, and the input is a number, it will be interpreted as a number of milliseconds.
Syntax:
{{ NumberOrString | duration([unit] }}
Parameters:
Parameter | Description |
|---|---|
| The unit of the duration number. One of |
Examples:
Format | Output |
|---|---|
| 3 |
|
|
|
|
2} | duration
Duration formatting
You might want to display duration in a specific format. Momentjs provides some methods to display duration in different formats.
humanize
Description:
Formats a Moment.js duration object into a user-friendly string. To format it in a specific locale (language), use the duration("locale") filter first. It applies to a Moment.js duration object, as returned by the duration([unit]) filter.
Syntax:
{{ durationObject | duration("humanize" [,relative]) }}
Parameters:
Parameter | Description |
|---|---|
| If |
Examples:
Format | Output |
|---|---|
|
|
|
|
|
|
|
|
locale
Description:
Specifies a locale to use for a subsequent duration("humanize") filter.
Syntax:
{{ durationObject | duration("locale", locale) }}
Parameters:
Parameter | Description |
|---|---|
| A two-letter locale identifier, such as |
Examples:
Format | Output |
|---|---|
|
|
|
|
Duration calculations
You might want to manipulate a duration before setting it to a field. For example, you might want to set a custom field to the difference of the Original estimate and Time Spent. Below are some methods to help with these manipulations.
add
Description:
Adds time to a Moment.js duration.
Syntax:
{{ durationObject | duration('add' , amount [, unit ] ) }}
Parameters:
Parameter | Description |
|---|---|
| The amount of time to add. Can be a number or another Moment.js duration object |
| The unit of the amount parameter. One of |
Examples:
Input | Details | Output |
|---|---|---|
| Returns the duration in milliseconds. |
|
| The number can be negative. Apply the |
|
| You can also pass them in object literal |
|
| Add an hour to the Original estimate of the issue. | Duration in milliseconds. For example |
| Adds the Remaining estimate and the Time Spent on the issue. | Duration as a relative time. For example |
subtract
Description:
Subtracts time from a Moment.js duration.
Syntax:
{{ durationObject | duration('subtract' , amount [, unit ] ) }}
Parameters:
Parameter | Description |
|---|---|
| The amount of time to subtract. Can be a number or another Moment.js duration object |
| The unit of the amount parameter. One of |
Examples:
Input | Details | Output |
|---|---|---|
| Returns the duration in milliseconds. |
|
| The number can be negative. Apply the duration filter to display the duration in days. | 9 |
| You can also pass them in object literal |
|
| Subtracts an hour to the Original estimate of the issue. | Duration in milliseconds. For example
|
| Subtracts the Remaining estimate and the Time Spent on the issue. | Duration as a relative time. For example
|
get
Description:
Returns a part of the Moment.js duration (milliseconds, seconds, minutes, ...)
Syntax:
{{ durationObject | duration([unit]) }}
Parameters:
Parameter | Description |
|---|---|
| The unit of the number to return. One of |
Examples:
Input | Output |
|---|---|
|
|
|
|
|
|
as
Description:
Converts a Moment.js duration into a number of milliseconds, or seconds, or minutes, ...
Syntax:
{{ durationObject | duration([unit]) }}
Parameters:
Parameter | Description |
|---|---|
| The unit of the number to return. One of |
Examples:
Input | Output |
|---|---|
|
|
|
|
|
|