That's pretty bad! This code handles the first set of examples, i.e.:
> 1/7/2002 11:59 pm = {ts '2002-07-01 23:59:00'}
> 1/7/2002 11:59:00 pm = {ts '2002-07-01 23:59:00'}
> 1/7/2002 11:59pm = {ts '2002-07-01 23:59:00'}
> 1/7/2002 11 pm = {ts '2002-07-01 23:00:00'}
> 1/7/2002 11pm = {ts '2002-07-01 23:00:00'}
> 1/7/2002 11.00 pm = {ts '2002-07-01 23:00:00'}
and with a bit of tweaking would work for all the examples except these two:
> January 25, 1999 8:30:00 = {ts '1999-01-25 08:30:00'}
> 8:30:00 Jan. 25, 1999 = {ts '1999-01-25 08:30:00'}
It would be easy to convert this to a UDF, and easyish to incorporate
support for the other formats as above. It's late here, but I might look at
it tomorrow. And, man, regexes are pretty neat, huh?
<cfset DateTime = "1/7/2002 11:59 pm">
<cfset SetLocale("English (US)")>
<cfset SearchResult =
REFind("^[[:space:]]*(([[:digit:]]+)[-/]([[:digit:]]+)[-/]([[:digit:]]+)[[:s
pace:]]+)?(([[:digit:]]+)([:.]([[:digit:]]+))?([:.]([[:digit:]]+))?[[:space:
]]*([[:alpha:].]*))?", DateTime, 1, "YES")>
<!--- debugging stuff
<cfdump var="#SearchResult#">
<cfloop index="i" from="1" to="#ArrayLen(SearchResult.Pos)#">
<cfoutput>
#i#:
<cftry>
#Mid(DateTime, SearchResult.Pos[i], SearchResult.Len[i])#
<cfcatch/>
</cftry>
<br>
</cfoutput>
</cfloop>
--->
<cfif SearchResult.Len[3]>
<cfset TheMonth = Mid(DateTime, SearchResult.Pos[3], SearchResult.Len[3])>
<cfelse>
<cfset TheMonth = 0>
</cfif>
<cfif SearchResult.Len[4]>
<cfset TheDay = Mid(DateTime, SearchResult.Pos[4], SearchResult.Len[4])>
<cfelse>
<cfset TheDay = 0>
</cfif>
<cfif SearchResult.Len[5]>
<cfset TheYear = Mid(DateTime, SearchResult.Pos[5], SearchResult.Len[5])>
<cfelse>
<cfset TheYear = 0>
</cfif>
<cfif SearchResult.Len[7]>
<cfset TheHour = Mid(DateTime, SearchResult.Pos[7], SearchResult.Len[7])>
<cfelse>
<cfset TheHour = 0>
</cfif>
<cfif SearchResult.Len[9]>
<cfset TheMinute = Mid(DateTime, SearchResult.Pos[9], SearchResult.Len[9])>
<cfelse>
<cfset TheMinute = 0>
</cfif>
<cfif SearchResult.Len[11]>
<cfset TheSecond = Mid(DateTime, SearchResult.Pos[11],
SearchResult.Len[11])>
<cfelse>
<cfset TheSecond = 0>
</cfif>
<cfif SearchResult.Len[12]>
<cfset AMPM = Mid(DateTime, SearchResult.Pos[12], SearchResult.Len[12])>
<cfif ListFindNoCase("pm,p.m.", AMPM)>
<cfset TheHour = TheHour + 12>
</cfif>
</cfif>
<cfset ParsedDateTime = CreateDateTime(TheYear, TheMonth, TheDay, TheHour,
TheMinute, TheSecond)>
<cfoutput>
#DateTime# --> #ParsedDateTime#
</cfoutput>
----- Original Message -----
From: "George Karabelas" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Tuesday, July 02, 2002 8:40 PM
Subject: CFMX and crippled ParseDateTime
>
> hi everyone,
>
> Just installed CFMX and while almost everything seems to be working ok
I've
> come across a major problem when using lsParseDateTime.. it can no longer
> parse dates and times outside of a certain java format.
>
> eg. I was once able able to pass these times and they'd be converted to
> datetime format.
>
> CF5.0 and previous:
>
> 1/7/2002 11:59 pm = {ts '2002-07-01 23:59:00'}
> 1/7/2002 11:59:00 pm = {ts '2002-07-01 23:59:00'}
> 1/7/2002 11:59pm = {ts '2002-07-01 23:59:00'}
> 1/7/2002 11 pm = {ts '2002-07-01 23:00:00'}
> 1/7/2002 11pm = {ts '2002-07-01 23:00:00'}
> 1/7/2002 11.00 pm = {ts '2002-07-01 23:00:00'}
>
> With CFMX I get this:
>
> 1/7/2002 11:59 pm {ts '2002-07-01 23:59:00'}
> 1/7/2002 11:59:00 pm - COULD NOT PARSE
> 1/7/2002 11:59pm - COULD NOT PARSE
> 1/7/2002 11 pm - COULD NOT PARSE
> 1/7/2002 11pm - COULD NOT PARSE
> 1/7/2002 11.00 pm - COULD NOT PARSE
>
> Taking a look at the CF5.0 documentation and using the example supplied
for
> parsedatetime I got these results with CF5:
>
> 8:30:00 = {ts '1899-12-30 08:30:00'}
> 20:30:00 = {ts '1899-12-30 20:30:00'}
> January 25, 1999 8:30:00 = {ts '1999-01-25 08:30:00'}
> 8:30:00 Jan. 25, 1999 = {ts '1999-01-25 08:30:00'}
> 1/25/1999 8:30:00 = {ts '1999-01-25 08:30:00'}
>
> But with MX:
>
> 8:30:00 = {ts '1899-12-30 08:30:00'}
> 20:30:00 = {ts '1899-12-30 20:30:00'}
> January 25, 1999 8:30:00 = COULD NOT PARSE
> 8:30:00 Jan. 25, 1999 = COULD NOT PARSE
> 1/25/1999 8:30:00 = COULD NOT PARSE
>
> Rather than reinvent the wheel (and rewrite hundreds of lines of code then
> retest our currently functioning systems), I'd like a function that would
> work just like lsParseDateTime v5.0. Is there a custom tag or function
> available that will do this?
>
> Thanks,
> George
>
>
>
>
>
>
>
>
>
> FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
> Archives: http://www.mail-archive.com/[email protected]/
> Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
>
______________________________________________________________________
Your ad could be here. Monies from ads go to support these lists and provide more
resources for the community. http://www.fusionauthority.com/ads.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists