Created
October 17, 2017 02:46
-
-
Save anonymous/bf26e26e54216aebd294885480b694d2 to your computer and use it in GitHub Desktop.
TryCF Gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cffunction name="tryNum"> | |
<cfargument name="n" type="any" required="true" /> | |
<cftry> | |
<cfscript> | |
setNum(n); | |
</cfscript> | |
<cfcatch> | |
<Cfdump var=#cfcatch.message#> | |
</cfcatch> | |
</cftry> | |
<br> | |
</cffunction> | |
<cffunction name="setNum"> | |
<cfargument name="n" type="numeric" required="true" /> | |
<cfdump var=#n#> | |
</cffunction> | |
<cffunction name="TestNumbers"> | |
<cfscript> | |
writeOutput("<h2>#getlocale()#</h2>"); | |
tryNum(1); | |
tryNum("1"); | |
tryNum("1.23"); | |
tryNum(1.23); | |
tryNum("4,5551.23"); | |
</cfscript> | |
</cffunction> | |
<cffunction name="tryDate"> | |
<cfargument name="d" type="any" required="true" /> | |
<cftry> | |
<cfscript> | |
setDate(d); | |
</cfscript> | |
<cfcatch> | |
<Cfdump var=#cfcatch.message#> | |
</cfcatch> | |
</cftry> | |
</cffunction> | |
<cffunction name="setDate"> | |
<cfargument name="d" type="date" required="true" /> | |
<cftry> | |
<cfdump var=#d#> | |
<cfdump var=#LsParseDateTime(d)#> | |
<cfdump var=#ParseDateTime(d)#> | |
<br> | |
<cfcatch> | |
<Cfdump var=#cfcatch.message#> | |
</cfcatch> | |
</cftry> | |
</cffunction> | |
<cffunction name="TestDates"> | |
<cfscript> | |
writeOutput("<h2>#getlocale()#</h2>"); | |
setDate("31-12-2017"); | |
setDate("12-31-2017"); | |
setDate("1-12-2017"); | |
setDate("12-1-2017"); | |
</cfscript> | |
</cffunction> | |
<cfoutput> | |
<h1>Dates</h1> | |
<cfscript> | |
setLocale("German (Standard)"); | |
testDates(); | |
setLocale("English (Australian)"); | |
testDates(); | |
setLocale("English (US)"); | |
testDates(); | |
</cfscript> | |
<h1>Numbers</h1> | |
<cfscript> | |
setLocale("German (Standard)"); | |
TestNumbers(); | |
setLocale("English (Australian)"); | |
TestNumbers(); | |
setLocale("English (US)"); | |
TestNumbers(); | |
</cfscript> | |
</cfoutput> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment