Library

DFA · Regular

An ISO date, YYYY-MM-DD

Any four-digit year, a month from 01 to 12 and a day from 01 to 31. The first digit of the month and of the day each decide what the second may be. Whether February has a 30th is beyond it — that would need the year’s remainder mod 4, and the month, together.

0, 1, 2, 3, 4…0, 1, 2, 3, 4…0, 1, 2, 3, 4…0, 1, 2, 3, 4…-011, 2, 3, 4, 5…0, 1, 2-01, 231, 2, 3, 4, 5…0, 1, 2, 3, 4…0, 1
The machine as drawn — 14 states, 81 transitions.

The author’s examples, run

2024-02-29 → accept1999-12-31 → accept2000-01-01 → accept2024-13-01 → reject2024-00-10 → reject2024-12-32 → reject24-12-01 → reject2024-1-01 → reject