## Calendar Contest Problem 4 — Savvyday 29 Oatmeal 94

View as PDF

Points: 10
Time limit: 1.0s
Memory limit: 128M

Author:
Problem type

Finally, you managed to calculate the Gregorian date from dates given by the Maya, and you were able to return to the 20th century. It's not 2021, but hey, it's better than nothing! (Or maybe you didn't, in which case you deserve what's coming.)

You found yourself in Redmond, WA, and somehow managed to convince Microsoft to hire you as a software engineer, at least until you could return to 2021 (or end up somewhere else, I guess). Your manager gave you a trivial task: to implement a function that can parse HTTP-style date and times in UTC and convert them into the standard ISO 8601 format, which you should be familiar with by now.

The HTTP date format looks like Sat, 29 Oct 1994 09:43:31 GMT. Essentially, it's a 3-letter day of the week, followed by a comma and a space, followed by the day of the month, followed by a space, followed by the 3-letter month name, followed by a space, followed by the year, followed by a space, followed by the time in HH:MM:SS format using a 24-hour clock, followed by a space, followed by either GMT or UTC.

Sounds simple, right? Well, not so fast. Since this function will be consuming data from the Internet, it's required to accept a lot of terribly broken dates. One such date you need to be able to process is Savvyday 29 Oatmeal 94. Good luck!

#### Input Specification

A line of ASCII text not exceeding 100 bytes in length.

#### Output Specification

The date and time in ISO 8601 format.

The following rules should be applied to guarantee reproducibility:

• If the input year is two digits, it should be upgraded to four digits in the range . It is guaranteed that the actual year represented will be in the range .
• If a field is absent, it should be filled from the date 2021-07-17T00:00:00Z.

#### Sample Input 1

Sat, 29 Oct 1994 09:43:31 GMT

#### Sample Output 1

1994-10-29T09:43:31Z

#### Sample Input 2

Savvyday 29 Oatmeal 94

#### Sample Output 2

1994-10-29T00:00:00Z