Created
December 1, 2010 21:22
-
-
Save chrismendis/724251 to your computer and use it in GitHub Desktop.
Change the dates returned by Tumblr's tweet.js callback to something like 12:00 PM Oct. 27th
This file contains 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
var prettyTweetDate = function (tweetDateFromJSON) { | |
var createDate = Date.parse(tweetDateFromJSON), | |
tweetDate = new Date(createDate), | |
tweetDateNum = tweetDate.getDate(), | |
tweetHours = tweetDate.getHours(), | |
tweetAMPM = (tweetHours < 12) ? "AM" : "PM", | |
tweetDateSuffix = "", | |
prettyTweetDateString = "", | |
months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; | |
tweetHours = (tweetHours < 13) ? tweetHours : tweetHours - 12; | |
if (tweetDateNum === 1 || tweetDateNum === 21 || tweetDateNum === 31) { | |
tweetDateSuffix = "st"; | |
} else if (tweetDateNum === 2 || tweetDateNum === 22) { | |
tweetDateSuffix = "nd"; | |
} else if (tweetDateNum === 3 || tweetDateNum === 23) { | |
tweetDateSuffix = "rd"; | |
} else { | |
tweetDateSuffix = "th"; | |
} | |
prettyTweetDateString += tweetHours + ":" + tweetDate.getMinutes() + " " + tweetAMPM + " " + months[tweetDate.getMonth()] + " " + tweetDateNum + tweetDateSuffix; | |
return prettyTweetDateString; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment