From a2c66d5b3a5d6490b996e770ecefb322f94980f1 Mon Sep 17 00:00:00 2001 From: Jesse Wierzbinski Date: Fri, 18 Oct 2024 15:00:47 +0200 Subject: [PATCH] refactor: :memo: Switch from ISO 8601 to RFC 3339 --- app/changelog/page.mdx | 2 ++ app/entities/page.mdx | 4 ++-- app/extensions/polls/page.mdx | 4 ++-- app/extensions/vanity/page.mdx | 2 +- app/federation/validation/page.mdx | 2 +- app/types/page.mdx | 20 ++------------------ 6 files changed, 10 insertions(+), 24 deletions(-) diff --git a/app/changelog/page.mdx b/app/changelog/page.mdx index 6f356f1..5b11000 100644 --- a/app/changelog/page.mdx +++ b/app/changelog/page.mdx @@ -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 diff --git a/app/entities/page.mdx b/app/entities/page.mdx index 2bad0d5..ab6d22c 100644 --- a/app/entities/page.mdx +++ b/app/entities/page.mdx @@ -24,8 +24,8 @@ Any field in an entity not marked as `required` may be omitted or set to `null`. Type of the entity. Custom types must follow [Extension Naming](/extensions#naming). - - Date and time when the entity was created. Must be an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) formatted string. + + Date and time when the entity was created. Must be an [RFC 3339](https://datatracker.ietf.org/doc/html/rfc3339) timestamp. Handling of dates that are valid but obviously incorrect (e.g. in the future) is left to the Implementation's discretion. diff --git a/app/extensions/polls/page.mdx b/app/extensions/polls/page.mdx index dc048d2..e7be043 100644 --- a/app/extensions/polls/page.mdx +++ b/app/extensions/polls/page.mdx @@ -29,8 +29,8 @@ Note that there is no `question` field: the question should be included in the ` Whether the poll allows multiple votes to be cast for different options. - - ISO 8601 timestamp of when the poll ends and no more votes can be cast. If not present, the poll does not expire. + + RFC 3339 timestamp of when the poll ends and no more votes can be cast. If not present, the poll does not expire. diff --git a/app/extensions/vanity/page.mdx b/app/extensions/vanity/page.mdx index 3b6d3bb..c6da43f 100644 --- a/app/extensions/vanity/page.mdx +++ b/app/extensions/vanity/page.mdx @@ -61,7 +61,7 @@ All properties are optional. type LanguageCode = string; ``` - + User's birthday. If year is left out or set to `0000`, implementations **SHOULD** not display the year. diff --git a/app/federation/validation/page.mdx b/app/federation/validation/page.mdx index a980085..493b04b 100644 --- a/app/federation/validation/page.mdx +++ b/app/federation/validation/page.mdx @@ -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. diff --git a/app/types/page.mdx b/app/types/page.mdx index bdf4524..d35e6fa 100644 --- a/app/types/page.mdx +++ b/app/types/page.mdx @@ -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