The document provides instructions for a program to calculate the total number of seconds between two input dates, taking into account leap years. The program must validate the dates by checking that the year, month, and day are valid numbers within ranges, and that the end date is not before the start date. It should output the exact same result as an online date duration calculator for 100% accuracy.
The document provides instructions for a program to calculate the total number of seconds between two input dates, taking into account leap years. The program must validate the dates by checking that the year, month, and day are valid numbers within ranges, and that the end date is not before the start date. It should output the exact same result as an online date duration calculator for 100% accuracy.
The document provides instructions for a program to calculate the total number of seconds between two input dates, taking into account leap years. The program must validate the dates by checking that the year, month, and day are valid numbers within ranges, and that the end date is not before the start date. It should output the exact same result as an online date duration calculator for 100% accuracy.
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