*=============================================== * Replacement for the built in CTOD() function * The original version causes two problems: * 1) it always add 19xx with 2-digit years * 2) it doesn't recognize "02/29/00". * Usage: Add the following line to every single * program or screen: * #DEFINE CTOD Y2K_CTOD *=============================================== Procedure Y2K_CToD Parameter tcDate *-------------------------------------------- * get date string. If a short date has been * given, and this date equals to "02/29/00", * we create a long date string. FoxPro will * convert a 4-digit-year properly, even if * SET CENTURY is OFF. *-------------------------------------------- Private lcDate, lcCentury If Len( tcDate ) <= 8 lcCentury = Set("Century") Set Century Off If tcDate == Sys(10,2451604) Set Century On lcDate = Sys(10,2451604) Else lcDate = tcdate Endif Set Century &lcCentury Else lcDate = tcDate Endif *-------------------------------------------- * convert into date format. Evaluate() is * necessarty, if #DEFINE CTOD is used and * this function is included into the main * program. Strings are not replaced by * #DEFINE, so we can nevertheless use CtoD * in a string *-------------------------------------------- Private ldDate ldDate = Evaluate("CToD(lcDate)") *-------------------------------------------- * Handle roll-over with 2-digit years *-------------------------------------------- If Len( tcDate ) <= 8 If Year( ldDate ) < Y2K_ROLLOVER lddate = GoMonth(ldDate,1200) Endif Endif Return ldDateChristof