-
Notifications
You must be signed in to change notification settings - Fork 9
Add AccurateDuration and NominalDuration #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AlexandreCarlton
wants to merge
2
commits into
graphql:main
Choose a base branch
from
AlexandreCarlton:add-accurate-duration-and-nominal-duration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<!-- cspell:ignore Alexandre --> | ||
|
||
# AccurateDuration — GraphQL Custom Scalar | ||
|
||
Author - AlexandreCarlton | ||
|
||
Date - 2024-03-17 | ||
|
||
**License and Copyright** | ||
|
||
Copyright © GraphQL contributors. This specification is licensed under | ||
[OWFa 1.0](https://www.openwebfoundation.org/the-agreements/the-owf-1-0-agreements-granted-claims/owfa-1-0). | ||
|
||
# Overview | ||
|
||
This Scalar represents an exact length in time. It is a refinement of the | ||
duration as defined by [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) with | ||
the caveat that it does not support calendar components that would otherwise | ||
require the knowledge of a date to determine a precise value. As such, the | ||
following components are excluded: | ||
|
||
- calendar year (as this can be potentially a leap year). | ||
- calendar month as this may contain a variable number of days). | ||
- calendar day (as this may contain leap seconds by decision of the | ||
[Internal Earth Rotation Service](https://en.wikipedia.org/wiki/International_Earth_Rotation_and_Reference_Systems_Service)). | ||
- calendar week (as this is seven calendar days). | ||
|
||
Days (unlike calendar days) are supported under the definition of | ||
[ISO 31-1](https://en.wikipedia.org/wiki/ISO_31-1): 24 hours. | ||
|
||
Negative durations per [ISO 8601-2](https://en.wikipedia.org/wiki/ISO_8601) are | ||
supported. | ||
|
||
# Name | ||
|
||
`AccurateDuration`, originating from the wording in | ||
[ISO 8601](https://en.wikipedia.org/wiki/ISO_8601): | ||
|
||
<blockquote>Duration can be expressed by a combination of components with accurate duration (hour, minute and second) | ||
and components with nominal duration (year, month, week and day).</blockquote> | ||
|
||
# Input/Result specification | ||
|
||
[ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) defines a duration as either: | ||
|
||
- `PnYnMnDTnHnMnS` | ||
- `PnW` | ||
|
||
Instead, the specification `PDTnHnMn.nS` is used, with the further amendments: | ||
|
||
- Year/Month/Week components are not supported. | ||
- Days are considered to be always 24 hours. | ||
- The entire string may be prefixed with a `-` to signify a negative duration. | ||
- Each component may be prefixed with a `-` to signify a negative component. | ||
- The seconds component (and only the seconds component) may have a fractional | ||
component of up to 9 digits. | ||
- Overflowing of components above their maximum (e.g. 60 for a minute) is | ||
allowed. For example, `PT90M` is valid and equivalent to `PT1H30M`. | ||
|
||
## Positive examples | ||
|
||
| String | Explanation | | ||
| ---------------- | -------------------------------------------------------- | | ||
| `PT2M` | A duration representing 2 minutes. | | ||
| `PT120S` | A duration representing 120 seconds (2 minutes). | | ||
| `PT0.000000001S` | A duration representing 1 nanosecond. | | ||
| `-P1D` | A duration representing 1 negative day. | | ||
| `P1D-2H` | A duration representing two hours fewer than a full day. | | ||
|
||
## Negative examples | ||
|
||
| String | Explanation | | ||
| ----------------- | --------------------------------------------------------------- | | ||
| `P1Y` | Calendar years are not supported. | | ||
| `P1M` | Calendar months are not supported. | | ||
| `P1W` | Calendar weeks are not supported. | | ||
| `P0.5D` | Fractional component is only supported for seconds. | | ||
| `PT0.0000000001S` | Fractional component in seconds only supports at most 9 digits. | | ||
| `PTS` | Digits must precede units. | | ||
|
||
# References | ||
|
||
- [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<!-- cspell:ignore Alexandre --> | ||
|
||
# AccurateDuration — GraphQL Custom Scalar | ||
|
||
Author - AlexandreCarlton | ||
|
||
Date - 2024-03-17 | ||
|
||
**License and Copyright** | ||
|
||
Copyright © GraphQL contributors. This specification is licensed under | ||
[OWFa 1.0](https://www.openwebfoundation.org/the-agreements/the-owf-1-0-agreements-granted-claims/owfa-1-0). | ||
|
||
# Overview | ||
|
||
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](https://en.wikipedia.org/wiki/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: | ||
|
||
- calendar year (as this can be potentially a leap year). | ||
- calendar month as this may contain a variable number of days). | ||
- calendar day (as this may contain leap seconds by decision of the | ||
[Internal Earth Rotation Service](https://en.wikipedia.org/wiki/International_Earth_Rotation_and_Reference_Systems_Service)). | ||
- calendar week (as this is seven calendar days). | ||
|
||
Negative durations per [ISO 8601-2](https://en.wikipedia.org/wiki/ISO_8601) are | ||
supported. | ||
|
||
# Name | ||
|
||
`NominalDuration`, originating from the wording in | ||
[ISO 8601](https://en.wikipedia.org/wiki/ISO_8601): | ||
|
||
<blockquote>Duration can be expressed by a combination of components with accurate duration (hour, minute and second) | ||
and components with nominal duration (year, month, week and day).</blockquote> | ||
|
||
# Input/Result specification | ||
|
||
[ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) defines a duration as either: | ||
|
||
- `PnYnMnDTnHnMnS` | ||
- `PnW` | ||
|
||
Instead, the specification `PnYnMnWnD` is used, with the further amendments: | ||
|
||
- The entire string may be prefixed with a `-` to signify a negative duration. | ||
- Each component may be prefixed with a `-` to signify a negative component. | ||
- A calendar week may be declared alongside calendar year/month/day components. | ||
|
||
## Positive 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. | | ||
|
||
## Negative 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. | | ||
|
||
# References | ||
|
||
- [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.