NominalDuration — GraphQL Custom Scalar

Author – AlexandreCarlton

Date - 2024-03-17

1Overview

This Scalar represents a length in time in years, months, weeks or days. It is a refinement of the duration as defined by ISO 8601 with the caveat that it only supports calendar components that require the knowledge of the particular calendar position with which the duration is being evaluated. As such, only the following components are included:

Negative durations per ISO 8601-2 are supported.

3Input/Result specification

ISO 8601 defines a duration as either:

Instead, the specification PnYnMnWnD is used, with the further amendments:

3.1Positive examples

String Explanation
P1Y A duration representing a calendar year.
P2W A duration representing two calendar weeks.
-P1Y2M A negative duration representing a calendar year and calendar month.
P1Y-2M A duration representing a two calendar months fewer than a calendar year.
P2M3W A duration representing a two calendar months and three calendar weeks.
P24M A duration representing a twenty four calendar months.

3.2Negative examples

String Explanation
PT1H Hours are not supported.
PT1M Minutes are not supported.
PT1S Seconds are not supported.
P1.5Y Fractional components are not supported.
PY Digits must precede units.

4References

  1. 1Overview
  2. 2Recommended name
  3. 3Input/Result specification
    1. 3.1Positive examples
    2. 3.2Negative examples
  4. 4References