Revision: 38162
Updated Code
at December 27, 2010 16:20 by parkerkrhoyt
Updated Code
<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>
Revision: 38161
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 27, 2010 16:18 by parkerkrhoyt
Initial Code
<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>
Initial URL
Initial Description
Parsing an RSS date/time value (as a string) into a date/time object in ColdFusion. And more additional text.
Initial Title
Parse an RSS Date/Time String Into a Date/Time Object
Initial Tags
object, date
Initial Language
ColdFusion