Skip to content

Instantly share code, notes, and snippets.

@tomviner
Created February 27, 2013 10:22
Show Gist options
  • Save tomviner/5046919 to your computer and use it in GitHub Desktop.
Save tomviner/5046919 to your computer and use it in GitHub Desktop.
The next Redmine update: keep relative times up-to-date
// locate and parse all relative time links on the page
var reDate = /(\d+)\/(\d+)\/(\d+)/;
jQuery('a[title]').map(function(){
var a = jQuery(this);
if ((a.text() && a.text().length===0) || !a.attr('title').match(reDate) ){return 0}
var d = new Date(a.attr('title').replace(reDate, "$3/$2/$1"));
return 'make_relative('+d+')';
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment