Skip to content

Instantly share code, notes, and snippets.

@markhepburn
Created July 24, 2010 08:43
Show Gist options
  • Save markhepburn/488546 to your computer and use it in GitHub Desktop.
Save markhepburn/488546 to your computer and use it in GitHub Desktop.
var re = /\d{6}/,
dt = re.exec(document.location.href)[0];
var m = dt.slice(0,2),
d = dt.slice(2,4),
y = dt.slice(4);
y = y.charAt(0)==='0' ? '20'+y : '19'+y;
dt = newDate(y, parseInt(m,10)-1, d);
dt.setDate(dt.getDay()===5 ? dt.getDate()+3 : dt.getDate()+2);
y = dt.getFullYear().toString().slice(2);
m = dt.getMonth(); m++; m = m.toString();
if (m.length ===1) m = '0' + m;
d = dt.getDate().toString();
if (d.length === 1) d = '0' + d;
document.location.href = document.location.href.replace(re, m+d+y);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment