I want to find solution to the next problem, but I need to write EBNF of time in two formats, year-month-day and month-day-year to see the differences:
Identify one advantage of writing dates as a structured-integer in the form: year, month, day (1954-02-10) instead of in the normal order (02-10-1954).
Format: year-month-day. Here is what I came up with:
<NonZeroDigit> ::= ("1" | "2" | ... | "9")
<Month> ::= ( "0" <NonZeroDigit> ) | ( "1" ( "0" | "1" | "2" ) )
<Day> ::= ( "0" <NonZeroDigit> ) | ( ("1" | "2") <NonZeroDigit> ) | ("3" ( "0" | "1" ) )
<Year> ::= ( "000" <NonZeroDigit> ) |
( "00" <NonZeroDigit> <NonZeroDigit> ) |
( "0" <NonZeroDigit> <NonZeroDigit> <NonZeroDigit> ) |
( "1" <NonZeroDigit> <NonZeroDigit> <NonZeroDigit>) |
( "20" <NonZeroDigit> <NonZeroDigit> ) )
The year goes to 2099 which I guess its ok and these rules work but is there a better way to write EBNF of the time? Do I miss something?