;; | ---------------------------------------------------------------------------- ;; | MI_DateFmtOk ;; | ---------------------------------------------------------------------------- ;; | Function : Check if date format is Okay ;; | Arguments: dd - Day portion of the date ;; | mm - Month portion of the date ;; | yyyy - Year portion of the date ;; | Return : T if format is correct nil otherwise ;; | Updated : January 20, 1999 ;; | Comment : The correct format for a date is mm/dd/yyyy, in which each of the ;; | values dd, mm and yyyy must meet criteria for validity including the ;; | Y2K compliance to 4 digits for year and also the Year 2000 February ;; | moth of 30 days. ;; | Checks for leap and 400-multiple years also ;; | e-mail : rakesh.rao@4d-technologies.com ;; | Web : www.4d-technologies.com ;; | ---------------------------------------------------------------------------- (defun MI_DateFmtOk (dd mm yyyy / Ok ) (setq Ok nil) (if (and (and (>= yyyy 1900) (<= yyyy 9999)) (MI_InBetween mm 1 12) ) (progn (cond ((member mm (list 1 3 5 7 8 10 12)) ; 31-day month (if (MI_InBetween dd 1 31) (setq Ok T) ) ) ((member mm (list 4 6 9 11)) ; 30-day month (if (MI_InBetween dd 1 30) (setq Ok T) ) ) ((= mm 2) ; February (cond ((= (rem yyyy 400) 0) ; Year 2000 kind of leap year (30 days in February) (if (MI_InBetween dd 1 30) (setq Ok T) ) ) (T (if (= (rem yyyy 4) 0) (progn (if (MI_InBetween dd 1 29) (setq Ok T) ) ) (progn (if (MI_InBetween dd 1 28) (setq Ok T) ) )) ) ) ) ) ) ) (if Ok (strcat (ST_StrZ dd 2) "/" (ST_StrZ mm 2) "/" (itoa yyyy)) nil ) )