[Elecraft] KCOMM for K3
rydodd at yahoo.com
rydodd at yahoo.com
Sun Aug 1 10:28:03 EDT 2021
>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
More information about the Elecraft
mailing list