Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Write a bulletproof date validation routine.
#41
Quote:
Code:
IF year / 4 = INT(year / 4) THEN
Dark Ninja, your code for testing whether a year is a leap year is incorrect. The definition of a leap year (they added something to it, but I can't remember what) is:
Leapyear
#1. Factor of 4
#2. Not a factor of 100
#3. Rule 2 drops if year is factor of 400

So, the proper code would be:
Code:
LeapYear = ((Year MOD 4 = 0 AND Year MOD 100 <> 0) OR (Year MOD 400 = 0))
IF LeapYear THEN blablabla

Hope you can do something with it Wink

EDIT:
Oh and:
Code:
IF day < 28 OR
Why are days lower than 28 invalid? :lol: That means your program will output 20000101 (1st Jan. 2000) as an invalid date.
Reply


Messages In This Thread
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
Write a bulletproof date validation routine. - by Neo - 11-20-2004, 05:50 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)