Created
December 19, 2012 22:04
-
-
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.
This file contains hidden or 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="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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No need for the monthAbrToNum function...80% less code :)