Fixed - task 197: Handle date wraparound for year boundary
http://code.google.com/p/google-refine/issues/detail?id=197 git-svn-id: http://google-refine.googlecode.com/svn/trunk@1979 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
90794d5039
commit
4d84733b8e
@ -69,16 +69,18 @@ function formatDate(d) {
|
|||||||
var today = Date.today();
|
var today = Date.today();
|
||||||
var tomorrow = Date.today().add({ days: 1 });
|
var tomorrow = Date.today().add({ days: 1 });
|
||||||
|
|
||||||
if (d.between(today, tomorrow)) {
|
if (d > today) {
|
||||||
return "today " + d.toString("h:mm tt");
|
return "today " + d.toString("h:mm tt");
|
||||||
} else if (d.between(last_week, today)) {
|
} else if (d.between(last_week, today)) {
|
||||||
var diff = Math.floor(today.getDayOfYear() - d.getDayOfYear());
|
var diff = Math.floor(today.getDayOfYear() - d.getDayOfYear());
|
||||||
return (diff <= 1) ? ("yesterday " + d.toString("h:mm tt")) : (diff + " days ago");
|
return (diff <= 1) ? ("yesterday " + d.toString("h:mm tt")) : (diff + " days ago");
|
||||||
} else if (d.between(last_month, today)) {
|
} else if (d.between(last_month, today)) {
|
||||||
var diff = Math.floor((today.getDayOfYear() - d.getDayOfYear()) / 7);
|
var diff = Math.floor((today.getDayOfYear() - d.getDayOfYear()) / 7);
|
||||||
|
if (diff < 0) {diff += 52;}
|
||||||
return (diff == 1) ? "a week ago" : diff.toFixed(0) + " weeks ago" ;
|
return (diff == 1) ? "a week ago" : diff.toFixed(0) + " weeks ago" ;
|
||||||
} else if (d.between(last_year, today)) {
|
} else if (d.between(last_year, today)) {
|
||||||
var diff = Math.floor(today.getMonth() - d.getMonth());
|
var diff = Math.floor(today.getMonth() - d.getMonth());
|
||||||
|
if (diff < 0) {diff += 12;}
|
||||||
return (diff == 1) ? "a month ago" : diff + " months ago";
|
return (diff == 1) ? "a month ago" : diff + " months ago";
|
||||||
} else {
|
} else {
|
||||||
var diff = Math.floor(today.getYear() - d.getYear());
|
var diff = Math.floor(today.getYear() - d.getYear());
|
||||||
@ -174,7 +176,7 @@ function renderProjects(data) {
|
|||||||
if (data && typeof data.code != 'undefined' && data.code == "ok") {
|
if (data && typeof data.code != 'undefined' && data.code == "ok") {
|
||||||
nameLink.text(name);
|
nameLink.text(name);
|
||||||
} else {
|
} else {
|
||||||
alert("Failed to rename project: " + data.message)
|
alert("Failed to rename project: " + data.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -262,10 +264,10 @@ function showVersion() {
|
|||||||
if ("releases" in window) {
|
if ("releases" in window) {
|
||||||
if (isThereNewRelease()) {
|
if (isThereNewRelease()) {
|
||||||
var container = $('<div id="notification-container">')
|
var container = $('<div id="notification-container">')
|
||||||
.appendTo(document.body)
|
.appendTo(document.body);
|
||||||
var notification = $('<div id="notification">')
|
var notification = $('<div id="notification">')
|
||||||
.text('New version! ')
|
.text('New version! ')
|
||||||
.appendTo(container)
|
.appendTo(container);
|
||||||
$('<a>')
|
$('<a>')
|
||||||
.addClass('notification-action')
|
.addClass('notification-action')
|
||||||
.attr("href", releases.homepage)
|
.attr("href", releases.homepage)
|
||||||
|
Loading…
Reference in New Issue
Block a user