Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Y2K - CTOD etc
Message
 
To
20/01/1999 01:47:03
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00177900
Message ID:
00177916
Views:
36
Hi Barry,

>Do any of these programs address legacy code containing CTOD routines, etc?

Yes, my Y2K solution has replacement functions for CTOD() and LUPDATE(). By adding the line #DEFINE CTOD Y2K_CTOD to the top of any program you can automatically use my solution without replacing all occurences in the code. This function looks like this:
	*===============================================
	* 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
Christof
--
Christof
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform