You are on page 1of 1

Final Bonus – seconds between two dates

FINAL BONUS (this is not compulsory)


Write a program which calculates the total seconds between two input dates.

Both the start date and the end date are included in the calculation.

Three criteria must be taken into account to identify leap years:


(1) The year can be evenly divided by 4;
(2) If the year can be evenly divided by 100, it is NOT a leap year, unless;
(3) The year is also evenly divisible by 400. Then it is a leap year.

input error checking:


(1) year, month, and day should all be at least 1
(2) month is between 1 ~ 12
(3) the date of a month should be valid
(4) only leap year can have Feb 29
(5) the end date cannot be earlier than the start date

Online version: https://www.timeanddate.com/date/durationresult.html

The output should be exactly the same as the online version, i.e., the accuracy is 100%.

You might also like