rendered paste bodyfunction get_local_time_for_date(time) {
system_date = new Date(time);
user_date = new Date();
//hacky as hell using regexp to extract from string and feed it back.
user_date = new Date().toGMTString();
regexp = /, (.*?) (.*?) (\d\d\d\d) (\d\d):(\d\d):(\d\d)/;
times = regexp.exec(user_date);
user_date = new Date(times[2]+' '+times[1]+', '+times[3]+' '+times[4]+':'+times[5]+':'+times[6]);
delta_minutes = Math.floor((user_date- system_date) / (60 * 1000));
if (Math.abs(delta_minutes) <= (8*7*24*60)) { // eight weeks... I'm lazy to count days for longer than that
distance = distance_of_time_in_words(delta_minutes);
if (delta_minutes < 0) {
return distance + ' from now';
} else {
return distance + ' ago';
}
} else {
return 'on ' + system_date.toLocaleDateString();
}
}