Reputation: 9
I want to know about how to represent the 'datetime' format such as "yyyy-MM-dd hh:mm" using EBNF.
Upvotes: 0
Views: 251
Reputation: 896
One possible way of formulating this using EBNF is shown below. The expression parses only legal years, months and timestamps. However, it allows any month to have up to 31 days.
Timestamp = [ "-" ] Year "-" Month "-" Day " " Time ;
Year = Digit Digit Digit Digit ;
Month = "0" Digit | "1" "0".."2" ;
Day = "0".."2" Digit | "3" "0".."1" ;
Time = Hour ":" Minute ;
Hour = "0".."1" Digit | "2" "0".."3" ;
Minute = "0".."5" Digit ;
Digit = "0".."9" ;
Upvotes: 0