Skip to content

Instantly share code, notes, and snippets.

@pketh
Last active December 17, 2015 12:59
Show Gist options
  • Save pketh/5613899 to your computer and use it in GitHub Desktop.
Save pketh/5613899 to your computer and use it in GitHub Desktop.
Date converter hack for the 'paragraphs' osx static blogging platform. Currently, it only outputs dates in a single format. This hack gives you friendly, flexible formatting.
$(document).ready(function(){
$( ".date" ).each(function( ) {
var month = $(this).text().substring(0,2);
var day = $(this).text().substring(7,9);
var year = $(this).text().substring(9,11);
if (month == 01) {
var month = 'Jan';
}
else if (month == 02) {
var month = 'Feb';
}
else if (month == 03) {
var month = 'Mar';
}
else if (month == 04) {
var month = 'Apr';
}
else if (month == 05) {
var month = 'May';
}
else if (month == 06) {
var month = 'Jun';
}
else if (month == 07) {
var month = 'Jul';
}
else if (month == 08) {
var month = 'Aug';
}
else if (month == 09) {
var month = 'Sep';
}
else if (month == 10) {
var month = 'Oct';
}
else if (month == 11) {
var month = 'Nov';
}
else if (month == 12) {
var month = 'Dec';
}
else {
var month = '???';
}
$(this).replaceWith('<span class="date">' + month + " " + day + '</span>');
}); // close date func
}); //close doc ready
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment