Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Revisions

5 of 5
Commonmark migration

Short Date into English Long Date

Convert short date format into English long date in as few bytes as possible.

Input

Input will be in the form of a string with format, yyyy-mm-dd, with zero padding optional for all values. You can assume that this is syntactically correct, but not necessarily a valid date. Negative year values do not need to be supported.

Output

You must convert the date into the English long date format (e.g. 14th February 2017). Zero padding here is not allowed.

If the date is invalid (e.g. 2011-02-29), then this must be recognised in some way. Throwing an exception is allowed.

More examples can be seen below.

Test Cases

"1980年05月12日" -> 12th May 1980
"2005年12月3日" -> 3rd December 2005
"150-4-21" -> 21st April 150
"2011-2-29" -> (error/invalid)
"1999-10-35" -> (error/invalid)
Gareth
  • 1.3k
  • 1
  • 8
  • 14

AltStyle によって変換されたページ (->オリジナル) /