From fa92d06d9fd3776eb4145c919e7a0ca9d306a6a8 Mon Sep 17 00:00:00 2001 From: Layomi Akinrinade Date: Wed, 28 Oct 2020 17:43:51 -0700 Subject: [PATCH 1/3] Mention support for RFC 3339 --- docs/standard/datetime/system-text-json-support.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/standard/datetime/system-text-json-support.md b/docs/standard/datetime/system-text-json-support.md index 9e67e8df0973c..a0238d840de5d 100644 --- a/docs/standard/datetime/system-text-json-support.md +++ b/docs/standard/datetime/system-text-json-support.md @@ -185,6 +185,8 @@ The following levels of granularity are defined for parsing: 2. "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'FFFFFFFZ" 3. "yyyy'-'MM'-'dd'T'HH':'mm':'ss('+'/'-')HH':'mm" 4. "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'FFFFFFF('+'/'-')HH':'mm" + + This level of granularity is compliant with [RFC 3339](https://tools.ietf.org/html/rfc3339#section-5.6), a widely adopted profile of ISO 8601 used for interchanging date and time information. If there are decimal fractions for seconds, there must be at least one digit; `2019-07-26T00:00:00.` is not allowed. While up to 16 fractional digits are allowed, only the first seven are parsed. Anything beyond that is considered a zero. @@ -208,6 +210,7 @@ The following levels of granularity are defined for formatting: Used to format a with fractional seconds but without offset information. 2. 'Date time' + 1. "yyyy'-'MM'-'dd'T'HH':'mm':'ssZ" Used to format a without fractional seconds but with a UTC offset. @@ -223,6 +226,8 @@ The following levels of granularity are defined for formatting: 4. "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'FFFFFFF('+'/'-')HH':'mm" Used to format a or with fractional seconds and with a local offset. + + This level of granularity is compliant with [RFC 3339](https://tools.ietf.org/html/rfc3339#section-5.6). If the [round-trip format](../base-types/standard-date-and-time-format-strings.md#the-round-trip-o-o-format-specifier) representation of a or instance has trailing zeros in its fractional seconds, then From b3644862ae8147217510d7c19536738ce4e3a75c Mon Sep 17 00:00:00 2001 From: Layomi Akinrinade Date: Wed, 28 Oct 2020 17:46:54 -0700 Subject: [PATCH 2/3] Update system-text-json-support.md --- docs/standard/datetime/system-text-json-support.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/standard/datetime/system-text-json-support.md b/docs/standard/datetime/system-text-json-support.md index a0238d840de5d..2ca603eca4f16 100644 --- a/docs/standard/datetime/system-text-json-support.md +++ b/docs/standard/datetime/system-text-json-support.md @@ -185,7 +185,7 @@ The following levels of granularity are defined for parsing: 2. "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'FFFFFFFZ" 3. "yyyy'-'MM'-'dd'T'HH':'mm':'ss('+'/'-')HH':'mm" 4. "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'FFFFFFF('+'/'-')HH':'mm" - + This level of granularity is compliant with [RFC 3339](https://tools.ietf.org/html/rfc3339#section-5.6), a widely adopted profile of ISO 8601 used for interchanging date and time information. If there are decimal fractions for seconds, there must be at least one digit; `2019-07-26T00:00:00.` is not allowed. @@ -210,7 +210,6 @@ The following levels of granularity are defined for formatting: Used to format a with fractional seconds but without offset information. 2. 'Date time' - 1. "yyyy'-'MM'-'dd'T'HH':'mm':'ssZ" Used to format a without fractional seconds but with a UTC offset. @@ -226,7 +225,7 @@ The following levels of granularity are defined for formatting: 4. "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'FFFFFFF('+'/'-')HH':'mm" Used to format a or with fractional seconds and with a local offset. - + This level of granularity is compliant with [RFC 3339](https://tools.ietf.org/html/rfc3339#section-5.6). If the [round-trip format](../base-types/standard-date-and-time-format-strings.md#the-round-trip-o-o-format-specifier) representation of a From 4cb485549b754bc3ee7b7b413752fb734b4f47e9 Mon Sep 17 00:00:00 2001 From: Layomi Akinrinade Date: Thu, 29 Oct 2020 15:10:07 -0700 Subject: [PATCH 3/3] Add more notes --- docs/standard/datetime/system-text-json-support.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/standard/datetime/system-text-json-support.md b/docs/standard/datetime/system-text-json-support.md index 2ca603eca4f16..7da9a7c5c42a2 100644 --- a/docs/standard/datetime/system-text-json-support.md +++ b/docs/standard/datetime/system-text-json-support.md @@ -186,7 +186,11 @@ The following levels of granularity are defined for parsing: 3. "yyyy'-'MM'-'dd'T'HH':'mm':'ss('+'/'-')HH':'mm" 4. "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'FFFFFFF('+'/'-')HH':'mm" - This level of granularity is compliant with [RFC 3339](https://tools.ietf.org/html/rfc3339#section-5.6), a widely adopted profile of ISO 8601 used for interchanging date and time information. + This level of granularity is compliant with [RFC 3339](https://tools.ietf.org/html/rfc3339#section-5.6), a widely adopted profile of ISO 8601 used for interchanging date and time information. However, there are a few restrictions in the System.Text.Json implementation. + + - RFC 3339 does not specify a maximum number of fractional-second digits, but specifies that at least one digit must follow the period, if a fractional-second section is present. The implementation in System.Text.Json allows up to 16 digits (to support interop with other programming languages and frameworks), but parses only the first seven. A will be thrown if there are more than 16 fractional second digits when reading `DateTime` and `DateTimeOffset` instances. + - RFC 3339 allows the "T" and "Z" characters to be "t" or "z" respectively, but allows applications to limit support to just the upper-case variants. The implementation in System.Text.Json requires them to be "T" and "Z". A will be thrown if input payloads contain "t" or "z" when reading `DateTime` and `DateTimeOffset` instances. + - RFC 3339 specifies that the date and time sections are separated by "T", but allows applications to separate them by a space (" ") instead. System.Text.Json requires date and time sections to be separated with "T". A will be thrown if input payloads contain a space (" ") when reading `DateTime` and `DateTimeOffset` instances. If there are decimal fractions for seconds, there must be at least one digit; `2019-07-26T00:00:00.` is not allowed. While up to 16 fractional digits are allowed, only the first seven are parsed. Anything beyond that is considered a zero.