The Meridian Expedition Archive is digitizing a century of field-clerk ledgers. Every ledger entry records its date the way clerks always wrote it in the field: an ordinal day such as "1st", "22nd", or "30th", a three-letter month abbreviation (one of Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec), and a four-digit year, separated by single spaces -- for example "21st Apr 1998".
Write a program that converts one such date stamp into the archive's canonical ISO form so every entry sorts and compares correctly: YYYY-MM-DD, where the year keeps all four digits and the month and day are always exactly two digits, zero-padded when necessary.
A single line containing the date stamp in the form <ordinal-day> <month-abbrev> <year>.
A single line containing the ISO date YYYY-MM-DD.
Example 1
Input
21st Oct 2052
Expected
2052-10-21
Explanation
The day token "21st" has numeric value 21, the month "Oct" is the 10th month, and the year is 2052, giving 2052-10-21.
Example 2
Input
6th Jun 1933
Expected
1933-06-06
Explanation
The day 6 must be zero-padded to "06", the month "Jun" is the 6th month (zero-padded "06"), giving 1933-06-06.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →