function prettyDate(date, mini) {
	if (!date) return '';

	if (typeof (date) == "string")
		date = new Date((date || "").replace(/-/g, "/").replace(/[TZ]/g, " ").replace(/\.[0-9]*/, ""));

	let diff = (((new Date()).getTime() - date.getTime()) / 1000);
	let day_diff = Math.floor(diff / 86400);

	if (isNaN(day_diff) || day_diff < 0) return '';

	if (mini) {
		// Return short format of time difference
		if (day_diff == 0) {
			if (diff < 60) {
				return __("now");
			} else if (diff < 3600) {
				return __("{0} m", [Math.floor(diff / 60)]);
			} else if (diff < 86400) {
				return __("{0} h", [Math.floor(diff / 3600)]);
			}
		} else {
			if (day_diff < 7) {
				return __("{0} D", [day_diff]);
			} else if (day_diff < 31) {
				return __("{0} W", [Math.ceil(day_diff / 7)]);
			} else if (day_diff < 365) {
				return __("{0} M", [Math.ceil(day_diff / 30)]);
			} else {
				return __("{0} Y", [Math.ceil(day_diff / 365)]);
			}
		}
	} else {
		// Return long format of time difference
		if (day_diff == 0) {
			if (diff < 60) {
				return __("Just now");
			} else if (diff < 120) {
				return __("1 minute ago");
			} else if (diff < 3600) {
				return __("{0} minutes ago", [Math.floor(diff / 60)]);
			} else if (diff < 7200) {
				return __("1 hour ago");
			} else if (diff < 86400) {
				return __("{0} hours ago", [Math.floor(diff / 3600)]);
			}
		} else {
			if (day_diff == 1) {
				return __("Yesterday");
			} else if (day_diff < 7) {
				return __("{0} days ago", [day_diff]);
			} else if (day_diff < 14) {
				return __("1 week ago");
			} else if (day_diff < 31) {
				return __("{0} weeks ago", [Math.ceil(day_diff / 7)]);
			} else if (day_diff < 62) {
				return __("1 month ago");
			} else if (day_diff < 365) {
				return __("{0} months ago", [Math.ceil(day_diff / 30)]);
			} else if (day_diff < 730) {
				return __("1 year ago");
			} else {
				return __("{0} years ago", [Math.ceil(day_diff / 365)]);
			}
		}
	}
}

frappe.provide("frappe.datetime");
window.comment_when = function(datetime, mini) {
	var timestamp = frappe.datetime.str_to_user ?
		frappe.datetime.str_to_user(datetime) : datetime;
	return '<span class="frappe-timestamp '
		+ (mini ? " mini" : "") + '" data-timestamp="' + datetime
		+ '" title="' + timestamp + '">'
		+ prettyDate(datetime, mini) + '</span>';
};
frappe.datetime.comment_when = comment_when;

frappe.datetime.refresh_when = function() {
	if (jQuery) {
		$(".frappe-timestamp").each(function() {
			$(this).html(prettyDate($(this).attr("data-timestamp"), $(this).hasClass("mini")));
		});
	}
};

setInterval(function() {
	frappe.datetime.refresh_when();
}, 60000); // refresh every minute

@@ -678,17 +678,17 @@
 __(%22%7B0%7D 
-D
+d
 %22, %5Bday_
@@ -749,9 +749,9 @@
 %7B0%7D 
-W
+w
 %22, %5B
@@ -892,17 +892,17 @@
 __(%22%7B0%7D 
-Y
+y
 %22, %5BMath
@@ -1050,9 +1050,9 @@
 __(%22
-J
+j
 ust 
@@ -1411,9 +1411,9 @@
 __(%22
-Y
+y
 este

fix case of timestamps