Team:KULeuven/Tools/New Day/Date Retriever

From 2008.igem.org

(Difference between revisions)
m
m
Line 19: Line 19:
var day = parseInt(dateTokens[0]);
var day = parseInt(dateTokens[0]);
-
var month = 0;
+
var month;
for (x in monthNames) {
for (x in monthNames) {
-
if(dateTokens[1] == monthNames[x]) {month += parseInt(x); break;}
+
if(dateTokens[1] == monthNames[x]) {month = parseInt(x) + 1; break;}
}
}
var year = parseInt(dateTokens[2]);
var year = parseInt(dateTokens[2]);
Line 34: Line 34:
/* Retrieves date ndays before this page date */
/* Retrieves date ndays before this page date */
function datePast(ndays) {
function datePast(ndays) {
-
var pastDate = new Date(pageDate().getDate());
+
var pastDate = new Date();
-
pastDate.setDate(pastDate().getDate() - parseInt(ndays));
+
pastDate.setDate(pageDate().getDate() - ndays);
return pastDate;
return pastDate;
}
}
Line 42: Line 42:
function dateFuture(ndays) {
function dateFuture(ndays) {
var futureDate = new Date();
var futureDate = new Date();
-
futureDate.setDate(pageDate().getDate() - parseInt(ndays));
+
futureDate.setDate(pageDate().getDate() + ndays);
return futureDate;
return futureDate;
}
}
Line 91: Line 91:
URL += date.getDate();
URL += date.getDate();
URL += '_';
URL += '_';
-
URL += monthNames[date.getMonth()];
+
URL += monthNames[date.getMonth() - 1];
URL += '_';
URL += '_';
URL += date.getFullYear();
URL += date.getFullYear();

Revision as of 08:38, 1 August 2008

<< return to notebook return to homepage >>
< previous friday ← yesterday tomorrow → next monday >