>function ValidDate(d: string): boolean;
>begin
 >  Result := (Length(d) = 10)
>     and (d[5] = DateSeparator)
>     and (d[8] = DateSeparator)
>     and Between(StrToIntDef(Copy(d,1,4),-1),1950,2020)
>     and Between(StrToIntDef(Copy(d,6,2),-1),1,12)
>     and Between(StrToIntDef(Copy(d,9,2),-1),1,31);
> end;
> > Don't know why the limit of 2020. It may be a feature of the Pascal 
> function. It may not.


All of these functions implementing this logic are not date specific functions. 
 'Copy' is just copying the year out of the string representation of the 
date.'StrToIntDef' is just converting those 4 characters to an integer (or -1 
if the conversion fails).'Between' is just returning 'True' if the integer 
falls between 1950 and 2020
I think 2020 was just arbitrarily picked as a year.  These kind of arbitrary 
decisions are usually limited to code using 2 digit years.In the day it wasn't 
uncommon to see logic that turned a two digit year to a 19xx date if the year 
was greater than something like 30 and 20xx if it was less than 30 or so.
Like many programs, this one has obviously outlived its expected longevity.
RichardK4KRW
  
______________________________________________________________
Elecraft mailing list
Home: http://mailman.qth.net/mailman/listinfo/elecraft
Help: http://mailman.qth.net/mmfaq.htm
Post: mailto:[email protected]

This list hosted by: http://www.qsl.net
Please help support this email list: http://www.qsl.net/donate.html
Message delivered to [email protected] 

Reply via email to