Team:KULeuven/Tools/New Day/Date Retriever

From 2008.igem.org

(Difference between revisions)
m
m
Line 2: Line 2:
<script type="text/javascript">
<script type="text/javascript">
-
var pageDate;
 
var monthNames = new Array('January', 'February', 'March', 'April', 'May',
var monthNames = new Array('January', 'February', 'March', 'April', 'May',
'June', 'July', 'August', 'September', 'October', 'November', 'December');
'June', 'July', 'August', 'September', 'October', 'November', 'December');
Line 38: Line 37:
function datePast(ndays) {
function datePast(ndays) {
var pastDate = new Date();
var pastDate = new Date();
-
pastDate.setDate(pageDate.getDate() - ndays);
+
pastDate.setDate(pageDate().getDate() - ndays);
return pastDate;
return pastDate;
}
}
Line 45: Line 44:
function dateFuture(ndays) {
function dateFuture(ndays) {
var futureDate = new Date();
var futureDate = new Date();
-
futureDate.setDate(pageDate.getDate() + ndays);
+
futureDate.setDate(pageDate().getDate() + ndays);
return futureDate;
return futureDate;
}
}
Line 51: Line 50:
/* Returns the date of Friday previous week */
/* Returns the date of Friday previous week */
function previousWeekFriday() {
function previousWeekFriday() {
-
var dayOfWeek = pageDate.getDay();
+
var dayOfWeek = pageDate().getDay();
var previousWeekFriday;
var previousWeekFriday;
switch(dayOfWeek) {
switch(dayOfWeek) {
-
case 0: previousWeekFriday.setDate(pageDate.getDate() - 9); break;
+
case 0: previousWeekFriday.setDate(pageDate().getDate() - 9); break;
-
default: previousWeekFriday.setDate(pageDate.getDate() - (dayOfWeek + 2));
+
default: previousWeekFriday.setDate(pageDate().getDate() - (dayOfWeek + 2));
}
}
Line 64: Line 63:
/* Returns the date of Monday next week */
/* Returns the date of Monday next week */
function nextWeekMonday() {
function nextWeekMonday() {
-
var dayOfWeek = pageDate.getDay();
+
var dayOfWeek = pageDate().getDay();
var nextWeekMonday;
var nextWeekMonday;
switch(dayOfWeek) {
switch(dayOfWeek) {
-
case 0: nextWeekMonday.setDate(pageDate.getDate() + 1); break;
+
case 0: nextWeekMonday.setDate(pageDate().getDate() + 1); break;
-
default: nextWeekMonday.setDate(pageDate.getDate() + (8 - dayOfWeek));
+
default: nextWeekMonday.setDate(pageDate().getDate() + (8 - dayOfWeek));
}
}
Line 77: Line 76:
/* Returns the date of Friday this week */
/* Returns the date of Friday this week */
function thisFriday() {
function thisFriday() {
-
var dayOfWeek = pageDate.getDay();
+
var dayOfWeek = pageDate().getDay();
var thisFriday;
var thisFriday;
switch(dayOfWeek) {
switch(dayOfWeek) {
-
case 0: thisFriday.setDate(pageDate.getDate() - 2); break;
+
case 0: thisFriday.setDate(pageDate().getDate() - 2); break;
-
case 6: thisFriday.setDate(pageDate.getDate() - 1); break;
+
case 6: thisFriday.setDate(pageDate().getDate() - 1); break;
-
default: thisFriday.setDate(pageDate.getDate() + (5 - dayOfWeek));
+
default: thisFriday.setDate(pageDate().getDate() + (5 - dayOfWeek));
}
}
Line 98: Line 97:
URL += date.getFullYear();
URL += date.getFullYear();
window.location.href = URL;
window.location.href = URL;
-
}
 
-
 
-
window.onload() {
 
-
pageDate = pageDate();
 
}
}
</script>
</script>

Revision as of 10:00, 31 July 2008

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