Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Damn Converting Dates
Message
 
À
03/10/2008 14:50:55
Jay Johengen
Altamahaw-Ossipee, Caroline du Nord, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
MS SQL Server
Divers
Thread ID:
01352632
Message ID:
01352668
Vues:
22
What about something like this (I did not put too much though, just an idea to build upon, error handling is sorely missing)
loDateToFormatTransformation	= Createobject('DateToFormatTransformation')
ldDate						= {^2008/01/01}

? loDateToFormatTransformation.getFormattedDate(ldDate, 'CCYYMMDD')
? loDateToFormatTransformation.getFormattedDate(ldDate, 'MMDDCCYY')
? loDateToFormatTransformation.getFormattedDate(ldDate, 'DDMMCCYY')
? loDateToFormatTransformation.getFormattedDate(ldDate, 'DDMMYY')
? loDateToFormatTransformation.getFormattedDate(ldDate, 'MMDDYY')
? loDateToFormatTransformation.getFormattedDate(ldDate, 'YYMMDD')


define class DateToFormatTransformation as Session
	function getFormattedDate(tdDate as Date, tcFormat as String) as String
		local loTransformation, lcDate, loException

		loTransformation		= Createobject(tcFormat)
		lcDate				= loTransformation.getFormattedDate(tdDate)
		return lcDate
	endfunc
enddefine


define class CCYYMMDD as Session
	function getFormattedDate(tdDate as Date) as String
		return Dtos(tdDate)
	endfunc
enddefine

define class MMDDCCYY as Session
	function getFormattedDate(tdDate as Date) as String
		return Transform(Month(tdDate), '@L 99') + Transform(Day(tdDate), '@L 99') + Transform(Year(tdDate))
	endfunc
enddefine

define class DDMMCCYY as Session
	function getFormattedDate(tdDate as Date) as String
		return Transform(Day(tdDate), '@L 99') + Transform(Month(tdDate), '@L 99') + Transform(Year(tdDate))
	endfunc
enddefine

define class DDMMYY as Session
	function getFormattedDate(tdDate as Date) as String
		return Transform(Day(tdDate), '@L 99') + Transform(Month(tdDate), '@L 99') + Right(Transform(Year(tdDate)), 2)
	endfunc
enddefine

define class MMDDYY as Session
	function getFormattedDate(tdDate as Date) as String
		return Transform(Month(tdDate), '@L 99') + Transform(Day(tdDate), '@L 99') + Right(Transform(Year(tdDate)), 2)
	endfunc
enddefine

define class YYMMDD as Session
	function getFormattedDate(tdDate as Date) as String
		return Right(Dtos(tdDate), 6)
	endfunc
enddefine
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform