A lighthouse keeper records the calendar date of every entry made in the station's logbook. Given the dates of two entries, determine the number of days that separate them on the calendar. The two dates may be given in either chronological order, and the answer should always be a non-negative count of days between them.
A single integer: the number of days between the two dates.
Example 1
Input
2020-01-15 2019-12-31
Expected
15
Explanation
From 2019-12-31 to 2020-01-15 is 1 day to reach 2020-01-01 plus 14 more days to reach the 15th, so exactly 15 days separate the two dates.
Example 2
Input
2023-06-01 2023-06-01
Expected
0
Explanation
Both entries are on the same date, so 0 days separate them.
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 →