HTML5.2のdates and timesで先発グレゴリオ暦の紀元前1年と10000年より未来は妥当な値になるのか
W3CのHTML5.2の2.4.5. Dates and timesと2.4.5.1. Monthsの内容に食い違いがあり0000-01
や10000-01
が妥当な月の文字列かどうか良く分からないという話
追記
各仕様の内容、HTMLチェッカーによる解釈では以下の通りです
仕様またはチェッカー | Month 0000-01 |
Month 10000-01 |
---|---|---|
HTML 5.2の2.4.5. Dates and times | 妥当 (*1) | 妥当ではない |
HTML 5.2の2.4.5.1. Months | 妥当ではない | 妥当 |
HTML Living Standard (*2) の2.3.5.1. Months | 妥当ではない | 妥当 |
Ready to check - Nu Html Checker (*3) | 妥当ではない (Error: Year cannot be less than 1.) |
妥当 (Warning: Year may be mistyped.(*4)) |
- 妥当 *1
between the proleptic year 0000, and the year 9999.
の記述を0000年を含むと解釈した。含まなければ妥当ではない- HTML Living Standard *2
- Last Updated を参照した
- Ready to check - Nu Html Checker *3
- 時点の実装による
- Warning: Year may be mistyped. *4
- 誤記の疑いとして警告が出ているだけで、エラーではない
HTML 5.2の2.4.5.1.、HTML Living Standard、Nu Html Checkerの判定が一致する事、HTML 5.2の2.4.5.のみ異なる判定となりNOTE内の記述であることから、2.4.5.のbetween the proleptic year 0000, and the year 9999.
の記述が誤りであろうと考える
また、本記事、本追記を書くにあたり、twitterにて もんど (@momdo_) さんから色々助言をいただいた
改めて感謝を申し上げる
2.4.5. Dates and timesのNoteには以下の記述があります
This specification encodes dates and times according to a common subset of the [ISO8601] standard for dates.
(中略)
Dates are expressed in the proleptic Gregorian calendar between the proleptic year 0000, and the year 9999. Other years cannot be encoded.
Dates and timesは標準日付 [ISO 8601] の共通サブセットに従って日付と時刻をエンコードし、年は先発グレゴリオ暦で0000年から9999年の間であるとされています
紀元0年は存在しませんが、ISO 8601で0000年は先発グレゴリオ暦の紀元前1年とされているので、値としては 0000 から 9999 の間で、範囲は先発グレゴリオ暦紀元前1年から9999年の間と読めます
一方、2.4.5.1. Monthsで定義される妥当な月の文字列は以下の通りです
A string is a valid month string representing a year year and month month if it consists of the following components in the given order:
- Four or more ASCII digits, representing year, where year > 0
- A U+002D HYPHEN-MINUS character (-)
- Two ASCII digits, representing the month month, in the range 1 ≤ month ≤ 12
つまり、年を表す4桁以上のASCII数字で0より大きい数、ハイフン (-)、月を表す2桁のASCII数字で1以上12以下、を連続させたものが妥当な月の文字列となります
上記によればDates and timesのNOTEの記述に関わらず、0000-01
は妥当な月を表す文字列ではありません (where year > 0
の条件に反する)
一方で、Dates and timesのNOTEでは最大9999-12
と読めますが、MonthsではFour or more ASCII digits
とあるので10000-01
も妥当な月を表す文字列です
between the proleptic year 0000, and the year 9999.
が 0000 と 9999 を含まないと解釈すれば0000-01
は妥当でないとして双方の内容が一致しますが、9999については疑問が残ります
個人的な感想としては、Dates and timesのDates are expressed in the proleptic Gregorian calendar between the proleptic year 0000, and the year 9999. Other years cannot be encoded.
の記述が単に余計で、NOTEで概要を説明しようとして他の箇所と矛盾する事を書いてしまっただけなのではないかと思うのですが、どうなのでしょうか
ちなみにHTML Living Standard — Last Updated 12 January 2018では2.3.5. Dates and timesのNOTEにbetween the proleptic year 0000, and the year 9999.の記述はないのでこの問題は生じません
その上で2.3.5.1. Monthsの妥当な月の文字列の年の部分の定義はFour or more ASCII digits, representing year, where year > 0
となっており、W3CのHTML5.2と同じです