Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Write a bulletproof date validation routine.
#1
Bulletproof date validation routine, subroutine or function.

GIVEN: An input string in the format of: YYYYMMDD

where:
YYYY is the year (past, present or future: from 1600 to 3999)
MM is the month
DD is the day

CHALLENGE: Read the date input string and make absolutely sure that the represented date is valid.

VALIDITY: To be valid:
* The year must be from 1600 to 3999)
* The month must be from 01 to 12
* The day must be from 01 to the last day of the above month, considering leap year.
* Obviously, if the date input string is not 8 bytes long, the date is invalid.

OUTPUT: The message "VALID" or "INVALID".

If you haven't needed this routine yet, for sure you will need it someday.

I will test most entries, and tell you if it works, or on what date it fails.
*****
Reply


Messages In This Thread
Write a bulletproof date validation routine. - by Moneo - 10-11-2004, 06:00 AM
My entry - by Meg - 10-11-2004, 09:03 PM
updated - by Meg - 10-12-2004, 08:01 PM
/nod - by Meg - 10-23-2004, 01:34 AM
Foo - by ToohTooh - 10-26-2004, 10:36 PM
Reply on Clarification Suggestion - by Neo - 10-26-2004, 11:37 PM
Re: Reply on Clarification Suggestion - by oracle - 10-27-2004, 02:00 AM
Hmm... - by ToohTooh - 10-27-2004, 02:12 PM
Re: Hmm... - by Neo - 10-27-2004, 10:12 PM
Thank you. - by ToohTooh - 11-01-2004, 04:54 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)