ISO 8601//ABNF

ISO 8601//ABNF

[1] ISO 8601:2004日時表現の構文 + ISO 8601:2000 にあって 2004年版で削除された構文 + JIS X 0301 で追加されている構文を ABNF で表したものです。

[2] >>1 の各仕様によって認められる値は date-time-representation に一致するはずです。 ABNF で表現できない/していない制約があるので、一致するからといって適合するとは限りません。

[4] この構文が規定と一致するかどうかは不確かです。 構文の詳細は ISO 8601の日時形式をご参照ください。

date-time-representation = date
                         / local-time / utc-time / time-with-offset
                         / date-time
                         / interval
                         / recursing-interval

date = calendar-date / ordinal-date / week-date / jp-date
calendar-date = year opt-hyphen month opt-hyphen day
              / year opt-hyphen month
              / year
              / century
              / obs-calendar-date
obs-calendar-date = century-year opt-hyphen month opt-hyphen day
                  / prefix-hyphen century-year opt-hyphen month
                  / prefix-hyphen century-year
                  / prefix-hyphen prefix-hyphen month opt-hyphen day
                  / prefix-hyphen prefix-hyphen prefix-hyphen day
ordinal-date = year opt-hyphen ordinal-day
             / obs-ordinal-date
obs-ordinal-date = century-year opt-hyphen ordinal-day
                 / prefix-hyphen ordinal-day
week-date = year opt-hyphen week opt-hyphen week-day
          / year opt-hyphen week
          / obs-week-date
obs-week-date = century-year opt-hyphen week opt-hyphen week-day
              / century-year opt-hyphen week
              / prefix-hyphen decard-year opt-hyphen week opt-hyphen week-day
              / prefix-hyphen decard-year opt-hyphen week
              / prefix-hyphen week opt-hyphen week-day
              / prefix-hyphen week
              / prefix-hyphen W prefix-hyphen week-day
jp-date = opt-gengou jp-year dot month dot day
time = hms
     / obs-time
obs-time = prefix-hyphen minute opt-colon second [fraction]
         / prefix-hyphen minute [fraction]
         / prefix-hyphen prefix-hyphen second [fraction]
hms = hour opt-colon minute opt-colon second [fraction]
    / hour opt-colon minute [fraction]
    / hour [fraction]
local-time = [T] time
utc-time = time Z
time-with-offset = time offset
offset = sign hour opt-colon minute
       / sign hour
zone = [Z / offset]

date-time = year opt-hyphen month opt-hyphen day opt-T hms zone
          / year opt-hyphen ordinal-day opt-T hms zone

year = 4DIGIT / sign 4*DIGIT
century = 2DIGIT / sign 2*DIGIT
century-year = 2DIGIT
decard-year = DIGIT
jp-year = 2DIGIT
month = 2DIGIT ;; 01-12
day = 2DIGIT ;; 01-days of month
ordinal-day = 3DIGIT ;; 001-days of year
week = W 2DIGIT ;; 01-weeks of year
week-day = DIGIT ;; 1-7
hour = 2DIGIT ;; 00-24
minute = 2DIGIT ;; 00-59
second = 2DIGIT ;; 00-60
fraction = decimal 1*DIGIT

opt-hyphen = [hyphen]
prefix-hyphen = [hyphen]
opt-gengou = [gengou]
opt-colon = [colon]
opt-T = [T]

duration = P n W
         / P [n Y] [n M] [n D] [T [n H] [n M] [n S]]
         / duration-alt
duration-alt = P duration-year opt-hyphen duration-month opt-hyphen duration-day [duration-alt-time]
             / P duration-year opt-hyphen duration-month
             / P duration-year opt-hyphen duration-ordial-day [duration-alt-time]
             / P duration-year
duration-alt-time = opt-T duration-hour opt-colon duration-minute opt-colon duration-second [fraction]
                  / opt-T duration-hour opt-colon duration-minute [fraction]
                  / opt-T duration-hour [fraction]

n = 1*DIGIT [fraction]
duration-year = 4DIGIT / sign 4*DIGIT
duration-month = 2DIGIT ;; 00-11
duration-day = 2DIGIT ;; 00-29
duration-ordinal-day = 3DIGIT ;; 000-355
duration-hour = 2DIGIT ;; 00-23
duration-minute = 2DIGIT ;; 00-59
duration-second = 2DIGIT ;; 00-59

interval = interval-start-end / interval-duration / interval-start-duration / interval-duration-end
interval-start-end = date-time slash end-date-time
interval-duration = duration
interval-start-duration = date-time slash duration
interval-duration-end = duration slash date-time
end-date-time = date-time
              / month opt-hyphen day opt-T hms zone
              / day opt-T hms zone
              / ordinal-day opt-T hms zone
              / opt-T hms zone

recurring-interval = R [n] slash interval

sign = "+" / minus
minus = "-" / <MINUS SIGN>
hyphen = "-" / <HYPHEN>
dot = "."
colon = ":"
decimal = "." / ","
slash = "/" / <DOUBLE HYPHEN>
D = "D"
H = "H"
M = "M"
P = "P"
R = "R"
S = "S"
W = "W"
T = "T"
Y = "Y"
Z = "Z"
gengou = "H" / "S" / "T" / "M" / "平" / "昭" / "大" / "明"
[3] RFC 3339 の附属書にも、 ISO 8601:1988 に基づく ABNF があります。