/ Published in: ColdFusion
Parsing an RSS date/time value (as a string) into a date/time object in ColdFusion.
And more additional text.
And more additional text.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<cffunction access="public" name="ParseAtomDate" returntype="date" displayname="ParseAtomDate" description="Parses a date from an Atom feed"> <cfargument name="feeddate" type="string" required="yes" displayname="The date in string format as displayed in the feed"> <cfset LOCAL.year = Left( ARGUMENTS.feeddate, 4 )/> <cfset LOCAL.year = LSParseNumber( LOCAL.year )/> <cfset LOCAL.start = Find( "-", ARGUMENTS.feeddate ) + 1/> <cfset LOCAL.end = Find( "-", ARGUMENTS.feeddate, LOCAL.start )/> <cfset LOCAL.month = Mid( ARGUMENTS.feeddate, LOCAL.start, LOCAL.end - LOCAL.start )/> <cfset LOCAL.month = LSParseNumber( LOCAL.month )/> <cfset LOCAL.start = LOCAL.end + 1/> <cfset LOCAL.end = Find( "T", ARGUMENTS.feeddate, LOCAL.start )/> <cfset LOCAL.day = Mid( ARGUMENTS.feeddate, LOCAL.start, LOCAL.end - LOCAL.start )/> <cfset LOCAL.day = LSParseNumber( LOCAL.day )/> <cfset LOCAL.start = LOCAL.end + 1/> <cfset LOCAL.end = Find( ":", ARGUMENTS.feeddate, LOCAL.start )/> <cfset LOCAL.hour = Mid( ARGUMENTS.feeddate, LOCAL.start, LOCAL.end - LOCAL.start )/> <cfset LOCAL.hour = LSParseNumber( LOCAL.hour )/> <cfset LOCAL.start = LOCAL.end + 1/> <cfset LOCAL.end = Find( ":", ARGUMENTS.feeddate, LOCAL.start )/> <cfset LOCAL.minute = Mid( ARGUMENTS.feeddate, LOCAL.start, LOCAL.end - LOCAL.start )/> <cfset LOCAL.minute = LSParseNumber( LOCAL.minute )/> <cfset LOCAL.start = LOCAL.end + 1/> <cfset LOCAL.end = Find( "-", ARGUMENTS.feeddate, LOCAL.start )/> <cfset LOCAL.second = Mid( ARGUMENTS.feeddate, LOCAL.start, LOCAL.end - LOCAL.start )/> <cfset LOCAL.second = LSParseNumber( LOCAL.second )/> <cfreturn CreateDateTime( LOCAL.year, LOCAL.month, LOCAL.day, LOCAL.hour, LOCAL.minute, LOCAL.second )/> </cffunction>