*=============================================== * 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 ldDate *=============================================== * Replacement for the built-in LUPDATE() * The original version causes two problems: * 1) it always add 19xx after 2000 * 2) it doesn't recognize 02/29/2000. * Usage: Add the following line to every single * program or screen: * #DEFINE LUPDATE Y2K_LUPDATE *=============================================== Procedure Y2K_LUpdate Parameter tuAlias *-------------------------------------------- * check for default work area *-------------------------------------------- If Parameters() == 0 tuAlias = Select() Endif *-------------------------------------------- * table opened in given work area? *-------------------------------------------- If Type( "tuAlias" ) == "N" ; and Empty(Dbf(tuAlias)) Return {} Endif *-------------------------------------------- * get date. Causes error, if tuAlias doesn't * exist. *-------------------------------------------- Private ldDate ldDate = Evaluate("LUpdate(tuAlias)") If Empty(lddate) ldDate = Y2K_022900() Else If Year( ldDate ) < Y2K_ROLLOVER lddate = GoMonth(ldDate,1200) Endif Endif Return ldDate