w3c / qtspecs

XSLT and XQuery Specifications - the source used to build the specs, and the errata
Other
30 stars 25 forks source link

[fo31] Incorrect picture string for RFC 1123 / IETF-style date #36

Open joewiz opened 2 years ago

joewiz commented 2 years ago

In https://www.w3.org/TR/xpath-functions-31/#func-parse-ietf-date, a note contains a picture string which should produce an RFC 1123 / IETF-style date:

An RFC 1123 date can be generated approximately using fn:format-dateTime with a picture string of "[FNn3], [D01] [MNn3] [Y04] [H01]:[m01]:[s01] [Z0000]".

Given a dateTime like 1994-06-06T07:29:35Z, applying fn:format-dateTime with this picture string should return:

Mon, 06 Jun 1994 07:29:35 +0000

But according to the documentation on the picture string at https://www.w3.org/TR/xpath-functions-31/#date-picture-string, to truncate the day of the week and the month to 3 letters, we should not append 3 but *,-3, and to ensure a 4-digit year, we should use Y0001 instead of Y04. In other words, the picture string should be:

"[FNn,*-3], [D01] [MNn,*-3] [Y0001] [H01]:[m01]:[s01] [Z0000]")

… instead of:

"[FNn3], [D01] [MNn3] [Y04] [H01]:[m01]:[s01] [Z0000]"

My testing in BaseX, eXist, and Saxon shows that the picture string from the spec fails to produce the expected output, whereas the modified picture string produces the expected output:

Mon, 06 Jun 1994 07:29:35 +0000

The test expression that produces this expected output:

format-dateTime(xs:dateTime("1994-06-06T07:29:35Z"), "[FNn,*-3], [D01] [MNn,*-3] [Y0001] [H01]:[m01]:[s01] [Z0000]")