Skip to content

Instantly share code, notes, and snippets.

@atuttle
Created December 19, 2012 22:04
Show Gist options
  • Save atuttle/4340972 to your computer and use it in GitHub Desktop.
Save atuttle/4340972 to your computer and use it in GitHub Desktop.
Fuck Twitter's stupid date formatting in its goddamn ear. Worst idea ever.
<cffunction name="unfuckTwitterDateTime">
<cfargument name="fucked" />
<cfargument name="GMTOffset" default="0" />
<cfset fucked = trim(fucked) />
<cfset var d = right(fucked, 4) & '-' & monthAbrToNum(mid(fucked, 5, 3)) & '-' & mid(fucked, 9, 2) />
<cfset var t = mid(fucked, 12, 8) />
<cfreturn dateAdd("h", GMTOffset, ParseDateTime(d & ' ' & t)) />
</cffunction>
<cffunction name="monthAbrToNum">
<cfargument name="mon" />
<cfswitch expression="#lcase(mon)#">
<cfcase value="jan">
<cfreturn "01" />
</cfcase>
<cfcase value="feb">
<cfreturn "02" />
</cfcase>
<cfcase value="mar">
<cfreturn "03" />
</cfcase>
<cfcase value="apr">
<cfreturn "04" />
</cfcase>
<cfcase value="may">
<cfreturn "05" />
</cfcase>
<cfcase value="jun">
<cfreturn "06" />
</cfcase>
<cfcase value="jul">
<cfreturn "07" />
</cfcase>
<cfcase value="aug">
<cfreturn "08" />
</cfcase>
<cfcase value="sep">
<cfreturn "09" />
</cfcase>
<cfcase value="oct">
<cfreturn "10" />
</cfcase>
<cfcase value="nov">
<cfreturn "11" />
</cfcase>
<cfcase value="dec">
<cfreturn "12" />
</cfcase>
</cfswitch>
</cffunction>
@samfarmer
Copy link

No need for the monthAbrToNum function...80% less code :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment