refactor: 📝 Switch from ISO 8601 to RFC 3339

This commit is contained in:
Jesse Wierzbinski 2024-10-18 15:00:47 +02:00
parent 6796a31d2b
commit a2c66d5b3a
No known key found for this signature in database
6 changed files with 10 additions and 24 deletions

View file

@ -18,6 +18,8 @@ This page lists changes since Working Draft 3. {{ className: 'lead' }}
- Removed the nonce from the [signature system](/signatures), replaced with `Versia-Signed-At` (timestamps).
- Standardize rate limits with [IETF draft draft-polli-ratelimit-headers-02](https://www.ietf.org/archive/id/draft-polli-ratelimit-headers-02.html).
- Added [Versia Links](/links).
- Switched from ISO 8601 to [RFC 3339](https://datatracker.ietf.org/doc/html/rfc3339) for timestamps.
- In most cases, the two are interchangeable, but RFC 3339 is more strict. Most implementations should not need to change anything.
## Since WD 3

View file

@ -24,8 +24,8 @@ Any field in an entity not marked as `required` may be omitted or set to `null`.
<Property name="type" type="string" required={true}>
Type of the entity. Custom types must follow [Extension Naming](/extensions#naming).
</Property>
<Property name="created_at" type="ISO8601" required={true} typeLink="/types#iso-8601">
Date and time when the entity was created. Must be an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) formatted string.
<Property name="created_at" type="RFC3339" required={true} typeLink="/types#rfc3339">
Date and time when the entity was created. Must be an [RFC 3339](https://datatracker.ietf.org/doc/html/rfc3339) timestamp.
<Note>
Handling of dates that are valid but obviously incorrect (e.g. in the future) is left to the Implementation's discretion.

View file

@ -29,8 +29,8 @@ Note that there is no `question` field: the question should be included in the `
<Property name="multiple_choice" type="boolean" required="true">
Whether the poll allows multiple votes to be cast for different options.
</Property>
<Property name="expires_at" type="ISO 8601" typeLink="/types#iso8601">
ISO 8601 timestamp of when the poll ends and no more votes can be cast. If not present, the poll does not expire.
<Property name="expires_at" type="RFC3339" typeLink="/types#rfc3339">
RFC 3339 timestamp of when the poll ends and no more votes can be cast. If not present, the poll does not expire.
</Property>
</Properties>
</Col>

View file

@ -61,7 +61,7 @@ All properties are optional.
type LanguageCode = string;
```
</Property>
<Property name="birthday" type="ISO8601" required={false} typeLink="/types#iso8601">
<Property name="birthday" type="RFC3339" required={false} typeLink="/types#rfc3339">
User's birthday. If year is left out or set to `0000`, implementations **SHOULD** not display the year.
</Property>
<Property name="location" type="string" required={false}>

View file

@ -17,7 +17,7 @@ Implementations **MUST** strictly validate all incoming data to ensure that it i
Things that should be validated include, but are not limited to:
- The presence of **all required fields**.
- The **format** of all fields (integers should not be strings, dates should be in ISO 8601 format, etc.).
- The **format** of all fields (integers should not be strings, timestamps should be in RFC 3339 format, etc.).
- The presence of **all required headers**.
- The presence of a **valid signature**.
- The **length** of all fields (for example, the `username` field on a `User` entity) should be at least 1 character long.

View file

@ -1,23 +1,7 @@
## ISO8601
## RFC3339
```typescript
type Year = `${number}${number}${number}${number}`;
type Month = `${"0" | "1"}${number}`;
type Day = `${"0" | "1" | "2" | "3"}${number}`;
type DateString = `${Year}-${Month}-${Day}`;
type Hour = `${"0" | "1" | "2"}${number}`;
type Minute = `${"0" | "1" | "2" | "3" | "4" | "5"}${number}`;
type Second = `${"0" | "1" | "2" | "3" | "4" | "5"}${number}`;
type TimeString = `${Hour}:${Minute}:${Second}`;
type Offset = `${"Z" | "+" | "-"}${Hour}:${Minute}`;
type ISO8601 = `${DateString}T${TimeString}${Offset}`;
```
[https://datatracker.ietf.org/doc/html/rfc3339](https://datatracker.ietf.org/doc/html/rfc3339)
## UUID