Skip to content

Duration

The Duration widget allows users to specify a time period, expressing it in various units (days, hours, minutes, etc.).

XML Fields

XPath identifies the stored duration. Template defines the ISO-8601 duration shape shown to the user, for example P0DT0H0M for days, hours, and minutes. ValidationGroup makes the duration participate when that group is checked. Hints supplies help text and Rules contains conditional formatting or validation.

Duration Template

The units of duration are defined using a template expression. If no template is provided, the default template P0DT0H0M (representing zero duration) is used.

Duration Expression Format

A duration expression adheres to the following structure:

  1. Begins with P
  2. Followed by year (Y), month (M), and day (D) units (optional, in that order).
  3. Followed by T (if time units are specified).
  4. Followed by hour (H), minute (M), and second (S) units (optional, in that order).

Unit Identifiers:

  • Y: Year
  • M: Month
  • D: Day
  • H: Hour
  • M: Minute
  • S: Second

Examples

  • P1D: 1 Day
  • P1M2D: 1 Month and 2 Days
  • P1MT8H: 1 Month and 8 Hours
  • PT2H: 2 Hours

Relative Date Specifiers

To enhance usability, the widget supports relative date specifiers in addition to the standard ISO-8601 duration format. These specifiers modify the date relative to the current date.

  • YB: Year Begin (beginning of the year)
  • YE: Year End (end of the year)
  • MB: Month Begin (beginning of the month)
  • ME: Month End (end of the month)
  • DB: Day Begin (beginning of the day)
  • DE: Day End (end of the day)

Relative Date Examples

  • P2YB: Adds 2 years to the current date, then sets the date to the beginning of that year.
  • P1M2DB: Adds 1 month and 2 days to the current date, then sets the date to the beginning of that day.
  • P1M2DE: Adds 1 month and 2 days to the current date, then sets the date to the end of that day.

Example

1
2
3
4
<Duration XPath="Time" Template="P0DT0H0M" ValidationGroup="">
    <Hints><![CDATA[]]></Hints>
    <Rules />
</Duration>