On my website, users enter their date of birth in the style xx.xx.xx
- three two-digit numbers separated by dots. Unfortunately, I forgot to tell the users exactly which format to use. All I know is that one section is used for the month, one for the date, and one for the year. The year is definitely in the 20th century (1900-1999), so the format 31.05.75
means 31 May 1975
. Also, I'm assuming everyone uses either the Gregorian or the Julian calendar.
Now, I want to go through my database to clear up the mess. I'd like to start by dealing with the users with the most ambiguous dates, that is, those where the range of possible dates is the biggest.
For example, the date 08.27.53
means 27 August 1953
in either the Gregorian or Julian calendar. The date in the Julian calendar is 13 days later, so the range is just 13 days
.
In contrast, the notation 01.05.12
can refer to many possible dates. The earliest is 12 May 1901 (Gregorian)
, and the latest is 1 May 1912 (Julian)
. The range is 4020 days
.
Rules
- Input is a string in the format
xx.xx.xx
, where each field is two digits and zero-padded. - Output is the number of days in the range.
- You can assume that the input will always be a valid date.
- You may not use any built-in date or calendar functions.
- Shortest code (in bytes) wins.
Testcases
01.00.31
=>12
29.00.02
=>0
(The only possibility is29 February 1900 (Julian)
)04.30.00
=>13
06.12.15
=>3291
5, May 1975
supposed to be31st
? Also, do we have to account for leap years? \$\endgroup\$