aboutsummaryrefslogtreecommitdiffstats
path: root/netx/net/sourceforge/jnlp
diff options
context:
space:
mode:
authorOmair Majid <[email protected]>2012-04-03 12:13:24 -0400
committerOmair Majid <[email protected]>2012-04-03 12:13:24 -0400
commit92413ff87b5c65f627624d6600a6a3733433bd23 (patch)
treebd1282f5a0690fdb10f7a2bd049a0dd3b46e6713 /netx/net/sourceforge/jnlp
parente73ab7ec0e381bfab6fce1e1b614d88791f2f326 (diff)
Fix pac tests
The testDateRange* tests were rewritten so date wrapping is handled correctly. Also fixes two bugs in pac-funcs.js (a missed return value and using getYear instead of getFullYear). 2012-04-03 Omair Majid <[email protected]> * netx/net/sourceforge/jnlp/runtime/pac-funcs.js: Replace incorrect use of getYear() with getFullYear(). (inYearMonthDateRange): Add missing conditional case. * tests/netx/pac/pac-funcs-test.js (runTest): New function. (runTests): Call runTest. (incDate): Deal with month/year wrapping around. (decDate): Removed. (testDateRange, testDateRange2, testDateRange3): Handle wrapping of month and days.
Diffstat (limited to 'netx/net/sourceforge/jnlp')
-rw-r--r--netx/net/sourceforge/jnlp/runtime/pac-funcs.js35
1 files changed, 20 insertions, 15 deletions
diff --git a/netx/net/sourceforge/jnlp/runtime/pac-funcs.js b/netx/net/sourceforge/jnlp/runtime/pac-funcs.js
index 5c1ff78..3028706 100644
--- a/netx/net/sourceforge/jnlp/runtime/pac-funcs.js
+++ b/netx/net/sourceforge/jnlp/runtime/pac-funcs.js
@@ -338,7 +338,7 @@ function dateRange() {
}
}
- function isDateInRange() {
+function isDateInRange() {
function isDate(date) {
if (typeof(date) === 'number' && (date <= 31 && date >= 1)) {
@@ -415,7 +415,7 @@ function dateRange() {
}
function inYearRange(today, year1, year2) {
- if (year1 <= today.getYear() && today.getYear() <= year2) {
+ if (year1 <= today.getFullYear() && today.getFullYear() <= year2) {
return true;
} else {
return false;
@@ -482,7 +482,7 @@ function dateRange() {
function inYearMonthRange(today, month1, year1, month2, year2) {
if (year1 === year2) {
- if (today.getYear() === year1) {
+ if (today.getFullYear() === year1) {
if (month1 <= today.getMonth() && today.getMonth() <= month2) {
return true;
} else {
@@ -493,14 +493,14 @@ function dateRange() {
}
}
if (year1 < year2) {
- if (year1 <= today.getYear() && today.getYear() <= year2) {
- if (today.getYear() === year1) {
+ if (year1 <= today.getFullYear() && today.getFullYear() <= year2) {
+ if (today.getFullYear() === year1) {
if (today.getMonth() >= month1) {
return true;
} else {
return false;
}
- } else if (today.getYear() === year2) {
+ } else if (today.getFullYear() === year2) {
if (today.getMonth() <= month2) {
return true;
} else {
@@ -515,12 +515,11 @@ function dateRange() {
} else {
return false;
}
-
}
function inYearMonthDateRange(today, date1, month1, year1, date2, month2, year2) {
if (year1 === year2) {
- if (year1 === today.getYear()) {
+ if (year1 === today.getFullYear()) {
if ((month1 <= today.getMonth()) && (today.getMonth() <= month2)) {
if (month1 === month2) {
if (date1 <= today.getDate() && today.getDate() <= date2) {
@@ -550,8 +549,8 @@ function dateRange() {
return false;
}
} else if (year1 < year2) {
- if (year1 <= today.getYear() && today.getYear() <= year2) {
- if (today.getYear() === year1) {
+ if (year1 <= today.getFullYear() && today.getFullYear() <= year2) {
+ if (today.getFullYear() === year1) {
if (today.getMonth() === month1) {
if (today.getDate() >= date1) {
return true;
@@ -563,11 +562,17 @@ function dateRange() {
} else {
return false;
}
- } else if (today.getYear() === year2) {
- if (today.getMonth() <= month2) {
-
- } else {
+ } else if (today.getFullYear() === year2) {
+ if (today.getMonth() === month2) {
+ if (today.getDate() <= date1) {
+ return true;
+ } else {
+ return false;
+ }
+ } else if (today.getMonth() < month2) {
return true;
+ } else {
+ return false;
}
} else {
return true;
@@ -617,7 +622,7 @@ function dateRange() {
return false;
}
} else { // year
- if (today.getYear() === arg) {
+ if (today.getFullYear() === arg) {
return true;
} else {
return false;