spreadsheet
typeScript/javascript spreadsheet parser, with formulas.
git clone https://git.vogt.world/spreadsheet.git
Log | Files | README.md
← Commit log
commit
message
[tests] labeling and logging sets of tests
author
Ben Vogt <[email protected]>
date
2017-04-30 18:05:25
stats
15 file(s) changed, 4769 insertions(+), 3573 deletions(-)
files
README.md
tests/CellTest.ts
tests/Formulas/DateFormulasTest.ts
tests/Formulas/DateFormulasTestTimeOverride.ts
tests/Formulas/EngineeringTest.ts
tests/Formulas/FinancialTest.ts
tests/Formulas/HelperTest.ts
tests/Formulas/LogicalTest.ts
tests/Formulas/MathTest.ts
tests/Formulas/StatisticalTest.ts
tests/Formulas/TextTest.ts
tests/SheetFormulaTest.ts
tests/SheetParseTest.ts
tests/SheetTest.ts
tests/utils/Asserts.ts
   1diff --git a/README.md b/README.md
   2index c2e8def..609e2e9 100644
   3--- a/README.md
   4+++ b/README.md
   5@@ -43,6 +43,8 @@ Right now we're just using the number of days since 1900, but we should check th
   6 
   7 ### Numbers with commas in them should still parse to numbers.
   8 
   9+### Ensure all formulas are tested inside of SheetFormulaTest.ts
  10+
  11 
  12 ## Testing Guidelines
  13 
  14diff --git a/tests/CellTest.ts b/tests/CellTest.ts
  15index 84b20f7..c00baa3 100644
  16--- a/tests/CellTest.ts
  17+++ b/tests/CellTest.ts
  18@@ -1,22 +1,31 @@
  19-import { Cell } from "../src/Cell"
  20-import { assertEquals, assertArrayEquals } from "./utils/Asserts"
  21+import {
  22+  Cell
  23+} from "../src/Cell";
  24+import {
  25+  assertEquals,
  26+  assertArrayEquals,
  27+  test
  28+} from "./utils/Asserts";
  29 
  30-//Test constructor
  31-var cell = new Cell("A1");
  32-assertEquals(cell.getColumn(), 0);
  33-assertEquals(cell.getRow(), 0);
  34-assertArrayEquals(cell.getDependencies(), []);
  35-assertEquals(cell.getId(), "A1");
  36-assertEquals(cell.getFormula(), null);
  37+test("Cell.constructor", function(){
  38+  var cell = new Cell("A1");
  39+  assertEquals(cell.getColumn(), 0);
  40+  assertEquals(cell.getRow(), 0);
  41+  assertArrayEquals(cell.getDependencies(), []);
  42+  assertEquals(cell.getId(), "A1");
  43+  assertEquals(cell.getFormula(), null);
  44+});
  45 
  46-//Test updateDependencies
  47-var one = new Cell("A1");
  48-one.updateDependencies(["B2", "C1", "D12", "D13"]);
  49-assertArrayEquals(one.getDependencies(), ["B2", "C1", "D12", "D13"]);
  50-one.updateDependencies(["M4"]);
  51-assertArrayEquals(one.getDependencies(), ["B2", "C1", "D12", "D13", "M4"]);
  52+test("Cell.updateDependencies", function(){
  53+  var one = new Cell("A1");
  54+  one.updateDependencies(["B2", "C1", "D12", "D13"]);
  55+  assertArrayEquals(one.getDependencies(), ["B2", "C1", "D12", "D13"]);
  56+  one.updateDependencies(["M4"]);
  57+  assertArrayEquals(one.getDependencies(), ["B2", "C1", "D12", "D13", "M4"]);
  58+});
  59 
  60-//Test setValue
  61-var v = new Cell("A1");
  62-v.setValue("100");
  63-assertEquals("100", v.getValue());
  64+test("Cell.setValue", function(){
  65+  var v = new Cell("A1");
  66+  v.setValue("100");
  67+  assertEquals("100", v.getValue());
  68+});
  69diff --git a/tests/Formulas/DateFormulasTest.ts b/tests/Formulas/DateFormulasTest.ts
  70index b66bf0e..cf0c7be 100644
  71--- a/tests/Formulas/DateFormulasTest.ts
  72+++ b/tests/Formulas/DateFormulasTest.ts
  73@@ -25,1989 +25,2008 @@ import {
  74 import * as ERRORS from "../../src/Errors";
  75 import {
  76   assertEquals,
  77-  catchAndAssertEquals
  78+  catchAndAssertEquals,
  79+  test
  80 } from "../utils/Asserts"
  81 
  82 
  83-// Test WORKDAY.INTL
  84-assertEquals(WORKDAY$INTL(DATE(1999, 2, 2), 10), DATE(1999, 2, 16));
  85-assertEquals(WORKDAY$INTL(DATE(1999, 10, 10), 100), DATE(2000, 2, 25));
  86-assertEquals(WORKDAY$INTL(DATE(1909, 12, 11), 222), DATE(1910, 10, 18));
  87-assertEquals(WORKDAY$INTL(DATE(1922, 4, 1), 1234), DATE(1926, 12, 23));
  88-assertEquals(WORKDAY$INTL(DATE(1945, 1, 14), 6000), DATE(1968, 1, 12));
  89-assertEquals(WORKDAY$INTL(DATE(1945, 1, 14), 6000, "0000011"), DATE(1968, 1, 12));
  90-assertEquals(WORKDAY$INTL(DATE(1945, 1, 14), 6000, "1000001"), DATE(1968, 1, 13));
  91-assertEquals(WORKDAY$INTL(DATE(1945, 1, 14), 6000, "1100001"), DATE(1973, 10, 13));
  92-assertEquals(WORKDAY$INTL(DATE(1945, 1, 14), 6000, "1110000"), DATE(1973, 10, 14));
  93-assertEquals(WORKDAY$INTL(DATE(1945, 1, 14), 6000, "1110001"), DATE(1983, 5, 14));
  94-assertEquals(WORKDAY$INTL(DATE(1945, 1, 14), 6000, 6), DATE(1968, 1, 14));
  95-catchAndAssertEquals(function() {
  96-  WORKDAY$INTL(12, 12, [12], false, 1);
  97-}, ERRORS.NA_ERROR);
  98-catchAndAssertEquals(function() {
  99-  WORKDAY$INTL(12);
 100-}, ERRORS.NA_ERROR);
 101-catchAndAssertEquals(function() {
 102-  WORKDAY$INTL("1992-1-1", "str");
 103-}, ERRORS.VALUE_ERROR);
 104-catchAndAssertEquals(function() {
 105-  WORKDAY$INTL("1992-1-1", 12, []);
 106-}, ERRORS.REF_ERROR);
 107-catchAndAssertEquals(function() {
 108-  WORKDAY$INTL("1992-1-1", 16, "000");
 109-}, ERRORS.NUM_ERROR);
 110-catchAndAssertEquals(function() {
 111-  WORKDAY$INTL("1992-1-1", 12, 9);
 112-}, ERRORS.NUM_ERROR);
 113-catchAndAssertEquals(function() {
 114-  WORKDAY$INTL("1992-1-1", 66, false);
 115-}, ERRORS.VALUE_ERROR);
 116+test("WORKDAY.INTL", function () {
 117+  assertEquals(WORKDAY$INTL(DATE(1999, 2, 2), 10), DATE(1999, 2, 16));
 118+  assertEquals(WORKDAY$INTL(DATE(1999, 10, 10), 100), DATE(2000, 2, 25));
 119+  assertEquals(WORKDAY$INTL(DATE(1909, 12, 11), 222), DATE(1910, 10, 18));
 120+  assertEquals(WORKDAY$INTL(DATE(1922, 4, 1), 1234), DATE(1926, 12, 23));
 121+  assertEquals(WORKDAY$INTL(DATE(1945, 1, 14), 6000), DATE(1968, 1, 12));
 122+  assertEquals(WORKDAY$INTL(DATE(1945, 1, 14), 6000, "0000011"), DATE(1968, 1, 12));
 123+  assertEquals(WORKDAY$INTL(DATE(1945, 1, 14), 6000, "1000001"), DATE(1968, 1, 13));
 124+  assertEquals(WORKDAY$INTL(DATE(1945, 1, 14), 6000, "1100001"), DATE(1973, 10, 13));
 125+  assertEquals(WORKDAY$INTL(DATE(1945, 1, 14), 6000, "1110000"), DATE(1973, 10, 14));
 126+  assertEquals(WORKDAY$INTL(DATE(1945, 1, 14), 6000, "1110001"), DATE(1983, 5, 14));
 127+  assertEquals(WORKDAY$INTL(DATE(1945, 1, 14), 6000, 6), DATE(1968, 1, 14));
 128+  catchAndAssertEquals(function() {
 129+    WORKDAY$INTL(12, 12, [12], false, 1);
 130+  }, ERRORS.NA_ERROR);
 131+  catchAndAssertEquals(function() {
 132+    WORKDAY$INTL(12);
 133+  }, ERRORS.NA_ERROR);
 134+  catchAndAssertEquals(function() {
 135+    WORKDAY$INTL("1992-1-1", "str");
 136+  }, ERRORS.VALUE_ERROR);
 137+  catchAndAssertEquals(function() {
 138+    WORKDAY$INTL("1992-1-1", 12, []);
 139+  }, ERRORS.REF_ERROR);
 140+  catchAndAssertEquals(function() {
 141+    WORKDAY$INTL("1992-1-1", 16, "000");
 142+  }, ERRORS.NUM_ERROR);
 143+  catchAndAssertEquals(function() {
 144+    WORKDAY$INTL("1992-1-1", 12, 9);
 145+  }, ERRORS.NUM_ERROR);
 146+  catchAndAssertEquals(function() {
 147+    WORKDAY$INTL("1992-1-1", 66, false);
 148+  }, ERRORS.VALUE_ERROR);
 149+});
 150 
 151 
 152-// Test WORKDAY
 153-assertEquals(WORKDAY(DATE(1999, 2, 2), 10), DATE(1999, 2, 16));
 154-assertEquals(WORKDAY(DATE(1999, 10, 10), 100), DATE(2000, 2, 25));
 155-assertEquals(WORKDAY(DATE(1909, 12, 11), 222), DATE(1910, 10, 18));
 156-assertEquals(WORKDAY(DATE(1922, 4, 1), 1234), DATE(1926, 12, 23));
 157-assertEquals(WORKDAY(DATE(1945, 1, 14), 6000), DATE(1968, 1, 12));
 158-assertEquals(WORKDAY(DATE(1945, 1, 14), 6000, [23855, 23856, 23857, 23858, 23859]), DATE(1968, 1, 17));
 159-assertEquals(WORKDAY(DATE(1945, 1, 14), 6000, 23859), DATE(1968, 1, 15));
 160-assertEquals(WORKDAY(DATE(2012, 5, 29), 1000, [41058, 41059, 41060, 41061, 41062]), DATE(2016, 4, 1));
 161-assertEquals(WORKDAY([DATE(1999, 2, 2)], [10]), DATE(1999, 2, 16));
 162-catchAndAssertEquals(function() {
 163-  WORKDAY();
 164-}, ERRORS.NA_ERROR);
 165-catchAndAssertEquals(function() {
 166-  WORKDAY(DATE(2012, 5, 29), 1000, [10], 11);
 167-}, ERRORS.NA_ERROR);
 168+test("WORKDAY", function () {
 169+  assertEquals(WORKDAY(DATE(1999, 2, 2), 10), DATE(1999, 2, 16));
 170+  assertEquals(WORKDAY(DATE(1999, 10, 10), 100), DATE(2000, 2, 25));
 171+  assertEquals(WORKDAY(DATE(1909, 12, 11), 222), DATE(1910, 10, 18));
 172+  assertEquals(WORKDAY(DATE(1922, 4, 1), 1234), DATE(1926, 12, 23));
 173+  assertEquals(WORKDAY(DATE(1945, 1, 14), 6000), DATE(1968, 1, 12));
 174+  assertEquals(WORKDAY(DATE(1945, 1, 14), 6000, [23855, 23856, 23857, 23858, 23859]), DATE(1968, 1, 17));
 175+  assertEquals(WORKDAY(DATE(1945, 1, 14), 6000, 23859), DATE(1968, 1, 15));
 176+  assertEquals(WORKDAY(DATE(2012, 5, 29), 1000, [41058, 41059, 41060, 41061, 41062]), DATE(2016, 4, 1));
 177+  assertEquals(WORKDAY([DATE(1999, 2, 2)], [10]), DATE(1999, 2, 16));
 178+  catchAndAssertEquals(function() {
 179+    WORKDAY();
 180+  }, ERRORS.NA_ERROR);
 181+  catchAndAssertEquals(function() {
 182+    WORKDAY(DATE(2012, 5, 29), 1000, [10], 11);
 183+  }, ERRORS.NA_ERROR);
 184+});
 185 
 186 
 187-// Test TIME
 188-assertEquals(TIME(10, 10, 10).toNumber(), 0.4237268518518518);
 189-assertEquals(TIME(34, 10, 10).toNumber(), 0.4237268518518518);
 190-assertEquals(TIME(29, 10, 10).toNumber(), 0.2153935185185185);
 191-assertEquals(TIME(13, 9, 6).toNumber(), 0.5479861111111111);
 192-assertEquals(TIME(3, 1, 14).toNumber(), 0.12585648148148149);
 193-assertEquals(TIME(0, 0, 0).toNumber(), 0);
 194-assertEquals(TIME(24, 0, 0).toNumber(), 0);
 195-assertEquals(TIME(23, 60, 0).toNumber(), 0);
 196-assertEquals(TIME(23, 59, 60).toNumber(), 0);
 197-assertEquals(TIME(18, 0, 0).toNumber(), 0.75);
 198-assertEquals(TIME(12, 0, 0).toNumber(), 0.5);
 199-assertEquals(TIME(6, 0, 0).toNumber(), 0.25);
 200-assertEquals(TIME(3, 0, 0).toNumber(), 0.125);
 201-assertEquals(TIME("3", ["0"], false).toNumber(), 0.125);
 202-catchAndAssertEquals(function() {
 203-  TIME();
 204-}, ERRORS.NA_ERROR);
 205-catchAndAssertEquals(function() {
 206-  TIME(1, 1);
 207-}, ERRORS.NA_ERROR);
 208-catchAndAssertEquals(function() {
 209-  TIME(1, 1, 1, 1);
 210-}, ERRORS.NA_ERROR);
 211-catchAndAssertEquals(function() {
 212-  TIME(-29, 10, 10);
 213-}, ERRORS.NUM_ERROR);
 214-catchAndAssertEquals(function() {
 215-  TIME(1, 1, []);
 216-}, ERRORS.REF_ERROR);
 217+test("TIME", function () {
 218+  assertEquals(TIME(10, 10, 10).toNumber(), 0.4237268518518518);
 219+  assertEquals(TIME(34, 10, 10).toNumber(), 0.4237268518518518);
 220+  assertEquals(TIME(29, 10, 10).toNumber(), 0.2153935185185185);
 221+  assertEquals(TIME(13, 9, 6).toNumber(), 0.5479861111111111);
 222+  assertEquals(TIME(3, 1, 14).toNumber(), 0.12585648148148149);
 223+  assertEquals(TIME(0, 0, 0).toNumber(), 0);
 224+  assertEquals(TIME(24, 0, 0).toNumber(), 0);
 225+  assertEquals(TIME(23, 60, 0).toNumber(), 0);
 226+  assertEquals(TIME(23, 59, 60).toNumber(), 0);
 227+  assertEquals(TIME(18, 0, 0).toNumber(), 0.75);
 228+  assertEquals(TIME(12, 0, 0).toNumber(), 0.5);
 229+  assertEquals(TIME(6, 0, 0).toNumber(), 0.25);
 230+  assertEquals(TIME(3, 0, 0).toNumber(), 0.125);
 231+  assertEquals(TIME("3", ["0"], false).toNumber(), 0.125);
 232+  catchAndAssertEquals(function() {
 233+    TIME();
 234+  }, ERRORS.NA_ERROR);
 235+  catchAndAssertEquals(function() {
 236+    TIME(1, 1);
 237+  }, ERRORS.NA_ERROR);
 238+  catchAndAssertEquals(function() {
 239+    TIME(1, 1, 1, 1);
 240+  }, ERRORS.NA_ERROR);
 241+  catchAndAssertEquals(function() {
 242+    TIME(-29, 10, 10);
 243+  }, ERRORS.NUM_ERROR);
 244+  catchAndAssertEquals(function() {
 245+    TIME(1, 1, []);
 246+  }, ERRORS.REF_ERROR);
 247+});
 248 
 249 
 250-// Test NETWORKDAYS$INTL
 251-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-1-30"), 22);
 252-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-1"), 263);
 253-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-4"), 264);
 254-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-5"), 265);
 255-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-6"), 266);
 256-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-7"), 267);
 257-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-8"), 268);
 258-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-9"), 268);
 259-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-1-30", "0000011"), 22);
 260-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-1", "0000011"), 263);
 261-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-4", "0000011"), 264);
 262-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-5", "0000011"), 265);
 263-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-6", "0000011"), 266);
 264-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-7", "0000011"), 267);
 265-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-8", "0000011"), 268);
 266-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-9", "0000011"), 268);
 267-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-1-30", 1), 22);
 268-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-1", 1), 263);
 269-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-4", 1), 264);
 270-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-5", 1), 265);
 271-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-6", 1), 266);
 272-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-7", 1), 267);
 273-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-8", 1), 268);
 274-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-9", 1), 268);
 275-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-1-6", "1110011"), 2);
 276-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-1-14", "1110011"), 4);
 277-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-1-30", "1110011"), 9);
 278-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-1-30", "0001110"), 17);
 279-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-2-22", "0001110"), 29);
 280-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-2-22", "0001110"), 239);
 281-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-2-22", "0000110"), 37);
 282-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-2-22", 1, [DATE(1992, 1, 10), DATE(1992, 1, 11), DATE(1992, 1, 12), DATE(1992, 1, 13), DATE(1992, 1, 14)]), 35);
 283-assertEquals(NETWORKDAYS$INTL(["1992-1-1"], ["1992-1-30"], ["0000011"]), 22);
 284-catchAndAssertEquals(function() {
 285-  NETWORKDAYS$INTL(12, 12, [12], false, 1);
 286-}, ERRORS.NA_ERROR);
 287-catchAndAssertEquals(function() {
 288-  NETWORKDAYS$INTL(12);
 289-}, ERRORS.NA_ERROR);
 290-catchAndAssertEquals(function() {
 291-  NETWORKDAYS$INTL("1992-1-1", "str");
 292-}, ERRORS.VALUE_ERROR);
 293-catchAndAssertEquals(function() {
 294-  NETWORKDAYS$INTL(12, 12, 1, ["1992-11-1"]);
 295-}, ERRORS.VALUE_ERROR);
 296-catchAndAssertEquals(function() {
 297-  NETWORKDAYS$INTL("1992-1-1", "1992-1-1", []);
 298-}, ERRORS.REF_ERROR);
 299-catchAndAssertEquals(function() {
 300-  NETWORKDAYS$INTL("1992-1-1", "1994-1-1", "000");
 301-}, ERRORS.NUM_ERROR);
 302-catchAndAssertEquals(function() {
 303-  NETWORKDAYS$INTL("1992-1-1", "1994-1-1", 9);
 304-}, ERRORS.NUM_ERROR);
 305-catchAndAssertEquals(function() {
 306-  NETWORKDAYS$INTL("1992-1-1", "1994-1-1", false);
 307-}, ERRORS.VALUE_ERROR);
 308+test("NETWORKDAYS$INTL", function () {
 309+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-1-30"), 22);
 310+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-1"), 263);
 311+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-4"), 264);
 312+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-5"), 265);
 313+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-6"), 266);
 314+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-7"), 267);
 315+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-8"), 268);
 316+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-9"), 268);
 317+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-1-30", "0000011"), 22);
 318+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-1", "0000011"), 263);
 319+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-4", "0000011"), 264);
 320+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-5", "0000011"), 265);
 321+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-6", "0000011"), 266);
 322+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-7", "0000011"), 267);
 323+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-8", "0000011"), 268);
 324+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-9", "0000011"), 268);
 325+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-1-30", 1), 22);
 326+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-1", 1), 263);
 327+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-4", 1), 264);
 328+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-5", 1), 265);
 329+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-6", 1), 266);
 330+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-7", 1), 267);
 331+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-8", 1), 268);
 332+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-9", 1), 268);
 333+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-1-6", "1110011"), 2);
 334+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-1-14", "1110011"), 4);
 335+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-1-30", "1110011"), 9);
 336+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-1-30", "0001110"), 17);
 337+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-2-22", "0001110"), 29);
 338+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-2-22", "0001110"), 239);
 339+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-2-22", "0000110"), 37);
 340+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-2-22", 1, [DATE(1992, 1, 10), DATE(1992, 1, 11), DATE(1992, 1, 12), DATE(1992, 1, 13), DATE(1992, 1, 14)]), 35);
 341+  assertEquals(NETWORKDAYS$INTL(["1992-1-1"], ["1992-1-30"], ["0000011"]), 22);
 342+  catchAndAssertEquals(function() {
 343+    NETWORKDAYS$INTL(12, 12, [12], false, 1);
 344+  }, ERRORS.NA_ERROR);
 345+  catchAndAssertEquals(function() {
 346+    NETWORKDAYS$INTL(12);
 347+  }, ERRORS.NA_ERROR);
 348+  catchAndAssertEquals(function() {
 349+    NETWORKDAYS$INTL("1992-1-1", "str");
 350+  }, ERRORS.VALUE_ERROR);
 351+  catchAndAssertEquals(function() {
 352+    NETWORKDAYS$INTL(12, 12, 1, ["1992-11-1"]);
 353+  }, ERRORS.VALUE_ERROR);
 354+  catchAndAssertEquals(function() {
 355+    NETWORKDAYS$INTL("1992-1-1", "1992-1-1", []);
 356+  }, ERRORS.REF_ERROR);
 357+  catchAndAssertEquals(function() {
 358+    NETWORKDAYS$INTL("1992-1-1", "1994-1-1", "000");
 359+  }, ERRORS.NUM_ERROR);
 360+  catchAndAssertEquals(function() {
 361+    NETWORKDAYS$INTL("1992-1-1", "1994-1-1", 9);
 362+  }, ERRORS.NUM_ERROR);
 363+  catchAndAssertEquals(function() {
 364+    NETWORKDAYS$INTL("1992-1-1", "1994-1-1", false);
 365+  }, ERRORS.VALUE_ERROR);
 366+});
 367 
 368 
 369-// Test NETWORKDAYS
 370-assertEquals(NETWORKDAYS("1992-1-1", "1992-1-30"), 22);
 371-assertEquals(NETWORKDAYS("1992-1-1", "1993-1-1"), 263);
 372-assertEquals(NETWORKDAYS("1992-1-1", "1993-1-4"), 264);
 373-assertEquals(NETWORKDAYS("1992-1-1", "1993-1-5"), 265);
 374-assertEquals(NETWORKDAYS("1992-1-1", "1993-1-6"), 266);
 375-assertEquals(NETWORKDAYS("1992-1-1", "1993-1-7"), 267);
 376-assertEquals(NETWORKDAYS("1992-1-1", "1993-1-8"), 268);
 377-assertEquals(NETWORKDAYS("1992-1-1", "1993-1-9"), 268);
 378-assertEquals(NETWORKDAYS("1992-1-1", "2000-4-24"), 2169);
 379-assertEquals(NETWORKDAYS("1992-1-1", false), -24003);
 380-assertEquals(NETWORKDAYS("2020-12-12", 0), -31555);
 381-assertEquals(NETWORKDAYS(12, 1423), 1008);
 382-assertEquals(NETWORKDAYS(12, 12), 1);
 383-assertEquals(NETWORKDAYS(DATE(1900, 1, 11), 12), 1);
 384-assertEquals(NETWORKDAYS(DATE(1998, 1, 1), DATE(1999, 1, 22)), 277);
 385-// Single holiday test
 386-assertEquals(NETWORKDAYS("1992-1-1", "1992-1-30", [DATEVALUE("1992-1-22")]), 21);
 387-assertEquals(NETWORKDAYS("1992-1-1", "1993-1-1", [DATEVALUE("1992-6-19")]), 262);
 388-assertEquals(NETWORKDAYS("1992-1-1", "1993-1-4", [DATEVALUE("1992-6-19")]), 263);
 389-assertEquals(NETWORKDAYS("1992-1-1", "1993-1-5", [DATEVALUE("1992-6-19")]), 264);
 390-assertEquals(NETWORKDAYS("1992-1-1", "1993-1-6", [DATEVALUE("1992-6-19")]), 265);
 391-assertEquals(NETWORKDAYS("1992-1-1", "1993-1-7", [DATEVALUE("1992-6-19"), DATEVALUE("1992-6-18")]), 265);
 392-assertEquals(NETWORKDAYS("1992-1-1", "1993-1-8", [DATEVALUE("1992-6-19")]), 267);
 393-assertEquals(NETWORKDAYS("1992-1-1", "1993-1-9", [DATEVALUE("1992-6-19")]), 267);
 394-assertEquals(NETWORKDAYS("1992-1-1", "2000-4-24", [DATEVALUE("1992-6-19")]), 2168);
 395-assertEquals(NETWORKDAYS("1992-1-1", false, [DATEVALUE("1991-6-19")]), -24002);
 396-assertEquals(NETWORKDAYS("2020-12-12", 0, [DATEVALUE("1992-6-19")]), -31554);
 397-assertEquals(NETWORKDAYS(12, 1423, [22]), 1008);// weekend and holdiay overlapping
 398-assertEquals(NETWORKDAYS(12, 1423, [20]), 1007);
 399-assertEquals(NETWORKDAYS(12, 12, [12]), 0);
 400-assertEquals(NETWORKDAYS(DATE(1998, 1, 1), DATE(1999, 1, 22), [DATE(1999, 1, 20)]), 276);
 401-catchAndAssertEquals(function() {
 402-  NETWORKDAYS(12, 12, [12], false);
 403-}, ERRORS.NA_ERROR);
 404-catchAndAssertEquals(function() {
 405-  NETWORKDAYS(12);
 406-}, ERRORS.NA_ERROR);
 407-catchAndAssertEquals(function() {
 408-  NETWORKDAYS("1992-1-1", "str");
 409-}, ERRORS.VALUE_ERROR);
 410-catchAndAssertEquals(function() {
 411-  NETWORKDAYS(12, 12, ["1992-11-1"]);
 412-}, ERRORS.VALUE_ERROR);
 413-catchAndAssertEquals(function() {
 414-  NETWORKDAYS("1992-1-1", "1992-1-1", []);
 415-}, ERRORS.REF_ERROR);
 416+test("NETWORKDAYS", function(){
 417+  assertEquals(NETWORKDAYS("1992-1-1", "1992-1-30"), 22);
 418+  assertEquals(NETWORKDAYS("1992-1-1", "1993-1-1"), 263);
 419+  assertEquals(NETWORKDAYS("1992-1-1", "1993-1-4"), 264);
 420+  assertEquals(NETWORKDAYS("1992-1-1", "1993-1-5"), 265);
 421+  assertEquals(NETWORKDAYS("1992-1-1", "1993-1-6"), 266);
 422+  assertEquals(NETWORKDAYS("1992-1-1", "1993-1-7"), 267);
 423+  assertEquals(NETWORKDAYS("1992-1-1", "1993-1-8"), 268);
 424+  assertEquals(NETWORKDAYS("1992-1-1", "1993-1-9"), 268);
 425+  assertEquals(NETWORKDAYS("1992-1-1", "2000-4-24"), 2169);
 426+  assertEquals(NETWORKDAYS("1992-1-1", false), -24003);
 427+  assertEquals(NETWORKDAYS("2020-12-12", 0), -31555);
 428+  assertEquals(NETWORKDAYS(12, 1423), 1008);
 429+  assertEquals(NETWORKDAYS(12, 12), 1);
 430+  assertEquals(NETWORKDAYS(DATE(1900, 1, 11), 12), 1);
 431+  assertEquals(NETWORKDAYS(DATE(1998, 1, 1), DATE(1999, 1, 22)), 277);
 432+  // Single holiday test
 433+  assertEquals(NETWORKDAYS("1992-1-1", "1992-1-30", [DATEVALUE("1992-1-22")]), 21);
 434+  assertEquals(NETWORKDAYS("1992-1-1", "1993-1-1", [DATEVALUE("1992-6-19")]), 262);
 435+  assertEquals(NETWORKDAYS("1992-1-1", "1993-1-4", [DATEVALUE("1992-6-19")]), 263);
 436+  assertEquals(NETWORKDAYS("1992-1-1", "1993-1-5", [DATEVALUE("1992-6-19")]), 264);
 437+  assertEquals(NETWORKDAYS("1992-1-1", "1993-1-6", [DATEVALUE("1992-6-19")]), 265);
 438+  assertEquals(NETWORKDAYS("1992-1-1", "1993-1-7", [DATEVALUE("1992-6-19"), DATEVALUE("1992-6-18")]), 265);
 439+  assertEquals(NETWORKDAYS("1992-1-1", "1993-1-8", [DATEVALUE("1992-6-19")]), 267);
 440+  assertEquals(NETWORKDAYS("1992-1-1", "1993-1-9", [DATEVALUE("1992-6-19")]), 267);
 441+  assertEquals(NETWORKDAYS("1992-1-1", "2000-4-24", [DATEVALUE("1992-6-19")]), 2168);
 442+  assertEquals(NETWORKDAYS("1992-1-1", false, [DATEVALUE("1991-6-19")]), -24002);
 443+  assertEquals(NETWORKDAYS("2020-12-12", 0, [DATEVALUE("1992-6-19")]), -31554);
 444+  assertEquals(NETWORKDAYS(12, 1423, [22]), 1008);// weekend and holdiay overlapping
 445+  assertEquals(NETWORKDAYS(12, 1423, [20]), 1007);
 446+  assertEquals(NETWORKDAYS(12, 12, [12]), 0);
 447+  assertEquals(NETWORKDAYS(DATE(1998, 1, 1), DATE(1999, 1, 22), [DATE(1999, 1, 20)]), 276);
 448+  catchAndAssertEquals(function() {
 449+    NETWORKDAYS(12, 12, [12], false);
 450+  }, ERRORS.NA_ERROR);
 451+  catchAndAssertEquals(function() {
 452+    NETWORKDAYS(12);
 453+  }, ERRORS.NA_ERROR);
 454+  catchAndAssertEquals(function() {
 455+    NETWORKDAYS("1992-1-1", "str");
 456+  }, ERRORS.VALUE_ERROR);
 457+  catchAndAssertEquals(function() {
 458+    NETWORKDAYS(12, 12, ["1992-11-1"]);
 459+  }, ERRORS.VALUE_ERROR);
 460+  catchAndAssertEquals(function() {
 461+    NETWORKDAYS("1992-1-1", "1992-1-1", []);
 462+  }, ERRORS.REF_ERROR);
 463+});
 464 
 465 
 466+test("SECOND", function() {
 467+  assertEquals(SECOND("8:10"), 0);
 468+  assertEquals(SECOND("8:11"), 0);
 469+  assertEquals(SECOND("8:44"), 0);
 470+  assertEquals(SECOND("8:70"), 0);
 471+  assertEquals(SECOND("8:120"), 0);
 472+  assertEquals(SECOND("8:10:22"), 22);
 473+  assertEquals(SECOND("8:11:12"), 12);
 474+  assertEquals(SECOND("8:44:09"), 9);
 475+  assertEquals(SECOND("8:70:02"), 2);
 476+  assertEquals(SECOND("8:120:44"), 44);
 477+  assertEquals(SECOND("8:120:104"), 44);
 478+  assertEquals(SECOND("1992-1-1 8:120:104"), 44);
 479+  assertEquals(SECOND(0.511111111111), 0);
 480+  catchAndAssertEquals(function() {
 481+    SECOND("8:10", 5);
 482+  }, ERRORS.NA_ERROR);
 483+  catchAndAssertEquals(function() {
 484+    SECOND();
 485+  }, ERRORS.NA_ERROR);
 486+  catchAndAssertEquals(function() {
 487+    SECOND("str");
 488+  }, ERRORS.VALUE_ERROR);
 489+  catchAndAssertEquals(function() {
 490+    SECOND(" ");
 491+  }, ERRORS.VALUE_ERROR);
 492+  catchAndAssertEquals(function() {
 493+    SECOND([]);
 494+  }, ERRORS.REF_ERROR);
 495+});
 496 
 497-// Test SECOND
 498-assertEquals(SECOND("8:10"), 0);
 499-assertEquals(SECOND("8:11"), 0);
 500-assertEquals(SECOND("8:44"), 0);
 501-assertEquals(SECOND("8:70"), 0);
 502-assertEquals(SECOND("8:120"), 0);
 503-assertEquals(SECOND("8:10:22"), 22);
 504-assertEquals(SECOND("8:11:12"), 12);
 505-assertEquals(SECOND("8:44:09"), 9);
 506-assertEquals(SECOND("8:70:02"), 2);
 507-assertEquals(SECOND("8:120:44"), 44);
 508-assertEquals(SECOND("8:120:104"), 44);
 509-assertEquals(SECOND("1992-1-1 8:120:104"), 44);
 510-assertEquals(SECOND(0.511111111111), 0);
 511-catchAndAssertEquals(function() {
 512-  SECOND("8:10", 5);
 513-}, ERRORS.NA_ERROR);
 514-catchAndAssertEquals(function() {
 515-  SECOND();
 516-}, ERRORS.NA_ERROR);
 517-catchAndAssertEquals(function() {
 518-  SECOND("str");
 519-}, ERRORS.VALUE_ERROR);
 520-catchAndAssertEquals(function() {
 521-  SECOND(" ");
 522-}, ERRORS.VALUE_ERROR);
 523-catchAndAssertEquals(function() {
 524-  SECOND([]);
 525-}, ERRORS.REF_ERROR);
 526 
 527+test("MINUTE", function() {
 528+  assertEquals(MINUTE("8:10"), 10);
 529+  assertEquals(MINUTE("8:11"), 11);
 530+  assertEquals(MINUTE("8:44"), 44);
 531+  assertEquals(MINUTE("8:70"), 10);
 532+  assertEquals(MINUTE("8:120"), 0);
 533+  assertEquals(MINUTE("8:10000pm"), 40);
 534+  assertEquals(MINUTE("28:10000"), 40);
 535+  assertEquals(MINUTE("14:23232:9999991"), 58);
 536+  assertEquals(MINUTE(["8:10"]), 10);
 537+  assertEquals(MINUTE("11:21222:2111pm"), 17);
 538+  assertEquals(MINUTE("11:21222:2111am"), 17);
 539+  assertEquals(MINUTE(""), 0);
 540+  assertEquals(MINUTE(0), 0);
 541+  assertEquals(MINUTE(1), 0);
 542+  assertEquals(MINUTE(false), 0);
 543+  assertEquals(MINUTE(true), 0);
 544+  assertEquals(MINUTE(0.8), 12);
 545+  assertEquals(MINUTE(0.5), 0);
 546+  assertEquals(MINUTE(0.25), 0);
 547+  assertEquals(MINUTE(0.125), 0);
 548+  assertEquals(MINUTE(0.0625), 30);
 549+  assertEquals(MINUTE(1.5), 0);
 550+  assertEquals(MINUTE(99.5), 0);
 551+  assertEquals(MINUTE("1969-7-6 5:05am"), 5);
 552+  catchAndAssertEquals(function() {
 553+    MINUTE("8:10", 5);
 554+  }, ERRORS.NA_ERROR);
 555+  catchAndAssertEquals(function() {
 556+    MINUTE();
 557+  }, ERRORS.NA_ERROR);
 558+  catchAndAssertEquals(function() {
 559+    MINUTE("str");
 560+  }, ERRORS.VALUE_ERROR);
 561+  catchAndAssertEquals(function() {
 562+    MINUTE(" ");
 563+  }, ERRORS.VALUE_ERROR);
 564+  catchAndAssertEquals(function() {
 565+    MINUTE([]);
 566+  }, ERRORS.REF_ERROR);
 567+});
 568 
 569-// Test MINUTE
 570-assertEquals(MINUTE("8:10"), 10);
 571-assertEquals(MINUTE("8:11"), 11);
 572-assertEquals(MINUTE("8:44"), 44);
 573-assertEquals(MINUTE("8:70"), 10);
 574-assertEquals(MINUTE("8:120"), 0);
 575-assertEquals(MINUTE("8:10000pm"), 40);
 576-assertEquals(MINUTE("28:10000"), 40);
 577-assertEquals(MINUTE("14:23232:9999991"), 58);
 578-assertEquals(MINUTE(["8:10"]), 10);
 579-assertEquals(MINUTE("11:21222:2111pm"), 17);
 580-assertEquals(MINUTE("11:21222:2111am"), 17);
 581-assertEquals(MINUTE(""), 0);
 582-assertEquals(MINUTE(0), 0);
 583-assertEquals(MINUTE(1), 0);
 584-assertEquals(MINUTE(false), 0);
 585-assertEquals(MINUTE(true), 0);
 586-assertEquals(MINUTE(0.8), 12);
 587-assertEquals(MINUTE(0.5), 0);
 588-assertEquals(MINUTE(0.25), 0);
 589-assertEquals(MINUTE(0.125), 0);
 590-assertEquals(MINUTE(0.0625), 30);
 591-assertEquals(MINUTE(1.5), 0);
 592-assertEquals(MINUTE(99.5), 0);
 593-assertEquals(MINUTE("1969-7-6 5:05am"), 5);
 594-catchAndAssertEquals(function() {
 595-  MINUTE("8:10", 5);
 596-}, ERRORS.NA_ERROR);
 597-catchAndAssertEquals(function() {
 598-  MINUTE();
 599-}, ERRORS.NA_ERROR);
 600-catchAndAssertEquals(function() {
 601-  MINUTE("str");
 602-}, ERRORS.VALUE_ERROR);
 603-catchAndAssertEquals(function() {
 604-  MINUTE(" ");
 605-}, ERRORS.VALUE_ERROR);
 606-catchAndAssertEquals(function() {
 607-  MINUTE([]);
 608-}, ERRORS.REF_ERROR);
 609 
 610+test("HOUR", function() {
 611+  assertEquals(HOUR("8:10"), 8);
 612+  assertEquals(HOUR("8am"), 8);
 613+  assertEquals(HOUR("8:10pm"), 20);
 614+  assertEquals(HOUR("8:10000pm"), 18);
 615+  assertEquals(HOUR("28:10000"), 2);
 616+  assertEquals(HOUR("14:23232:9999991"), 10);
 617+  assertEquals(HOUR(["8:10"]), 8);
 618+  assertEquals(HOUR("11:21222:2111pm"), 17);
 619+  assertEquals(HOUR("11:21222:2111am"), 5);
 620+  assertEquals(HOUR(""), 0);
 621+  assertEquals(HOUR(0), 0);
 622+  assertEquals(HOUR(1), 0);
 623+  assertEquals(HOUR(false), 0);
 624+  assertEquals(HOUR(true), 0);
 625+  assertEquals(HOUR(0.8), 19);
 626+  assertEquals(HOUR(0.5), 12);
 627+  assertEquals(HOUR(0.25), 6);
 628+  assertEquals(HOUR(0.125), 3);
 629+  assertEquals(HOUR(0.0625), 1);
 630+  assertEquals(HOUR(1.5), 12);
 631+  assertEquals(HOUR(99.5), 12);
 632+  assertEquals(HOUR("0.8"), 19);
 633+  assertEquals(HOUR("0.5"), 12);
 634+  assertEquals(HOUR("0.25"), 6);
 635+  assertEquals(HOUR("0.125"), 3);
 636+  assertEquals(HOUR("0.0625"), 1);
 637+  assertEquals(HOUR("1969-7-6 5am"), 5);
 638+  catchAndAssertEquals(function() {
 639+    HOUR("8:10", 5);
 640+  }, ERRORS.NA_ERROR);
 641+  catchAndAssertEquals(function() {
 642+    HOUR();
 643+  }, ERRORS.NA_ERROR);
 644+  catchAndAssertEquals(function() {
 645+    HOUR("str");
 646+  }, ERRORS.VALUE_ERROR);
 647+  catchAndAssertEquals(function() {
 648+    HOUR(" ");
 649+  }, ERRORS.VALUE_ERROR);
 650+  catchAndAssertEquals(function() {
 651+    HOUR([]);
 652+  }, ERRORS.REF_ERROR);
 653+});
 654 
 655-// Test HOUR
 656-assertEquals(HOUR("8:10"), 8);
 657-assertEquals(HOUR("8am"), 8);
 658-assertEquals(HOUR("8:10pm"), 20);
 659-assertEquals(HOUR("8:10000pm"), 18);
 660-assertEquals(HOUR("28:10000"), 2);
 661-assertEquals(HOUR("14:23232:9999991"), 10);
 662-assertEquals(HOUR(["8:10"]), 8);
 663-assertEquals(HOUR("11:21222:2111pm"), 17);
 664-assertEquals(HOUR("11:21222:2111am"), 5);
 665-assertEquals(HOUR(""), 0);
 666-assertEquals(HOUR(0), 0);
 667-assertEquals(HOUR(1), 0);
 668-assertEquals(HOUR(false), 0);
 669-assertEquals(HOUR(true), 0);
 670-assertEquals(HOUR(0.8), 19);
 671-assertEquals(HOUR(0.5), 12);
 672-assertEquals(HOUR(0.25), 6);
 673-assertEquals(HOUR(0.125), 3);
 674-assertEquals(HOUR(0.0625), 1);
 675-assertEquals(HOUR(1.5), 12);
 676-assertEquals(HOUR(99.5), 12);
 677-assertEquals(HOUR("0.8"), 19);
 678-assertEquals(HOUR("0.5"), 12);
 679-assertEquals(HOUR("0.25"), 6);
 680-assertEquals(HOUR("0.125"), 3);
 681-assertEquals(HOUR("0.0625"), 1);
 682-assertEquals(HOUR("1969-7-6 5am"), 5);
 683-catchAndAssertEquals(function() {
 684-  HOUR("8:10", 5);
 685-}, ERRORS.NA_ERROR);
 686-catchAndAssertEquals(function() {
 687-  HOUR();
 688-}, ERRORS.NA_ERROR);
 689-catchAndAssertEquals(function() {
 690-  HOUR("str");
 691-}, ERRORS.VALUE_ERROR);
 692-catchAndAssertEquals(function() {
 693-  HOUR(" ");
 694-}, ERRORS.VALUE_ERROR);
 695-catchAndAssertEquals(function() {
 696-  HOUR([]);
 697-}, ERRORS.REF_ERROR);
 698 
 699+test("TIMEVALUE", function() {
 700+  assertEquals(TIMEVALUE("1969-7-6"), 0);
 701+  assertEquals(TIMEVALUE("1969-7-6 8am"), 0.3333333333333333);
 702+  assertEquals(TIMEVALUE("1969-7-28 8:10"), 0.3402777777777778);
 703+  assertEquals(TIMEVALUE("2100-7-6 8:10pm"), 0.8402777777777778);
 704+  assertEquals(TIMEVALUE("1999-1-1 8:10000pm"), 0.7777777777777778);
 705+  assertEquals(TIMEVALUE("2012/1/1 28:10000"), 0.1111111111111111);
 706+  assertEquals(TIMEVALUE("2012/1/1 14:23232:9999991"), 0.45730324074074075);
 707+  assertEquals(TIMEVALUE(["2012/1/1 8:10"]), 0.3402777777777778);
 708+  assertEquals(TIMEVALUE("2012/1/1 11:21222:2111pm"), 0.7202662037037038);
 709+  assertEquals(TIMEVALUE("2012/1/1 11:21222:2111am"), 0.2202662037037037);
 710+  assertEquals(TIMEVALUE("8am"), 0.3333333333333333);
 711+  assertEquals(TIMEVALUE("8:10"), 0.3402777777777778);
 712+  assertEquals(TIMEVALUE("8:10pm"), 0.8402777777777778);
 713+  assertEquals(TIMEVALUE("8:10000pm"), 0.7777777777777778);
 714+  assertEquals(TIMEVALUE("28:10000"), 0.1111111111111111);
 715+  assertEquals(TIMEVALUE("14:23232:9999991"), 0.45730324074074075);
 716+  assertEquals(TIMEVALUE(["8:10"]), 0.3402777777777778);
 717+  assertEquals(TIMEVALUE("11:21222:2111pm"), 0.7202662037037038);
 718+  assertEquals(TIMEVALUE("11:21222:2111am"), 0.2202662037037037);
 719+  catchAndAssertEquals(function() {
 720+    TIMEVALUE("8:10", 5);
 721+  }, ERRORS.NA_ERROR);
 722+  catchAndAssertEquals(function() {
 723+    TIMEVALUE();
 724+  }, ERRORS.NA_ERROR);
 725+  catchAndAssertEquals(function() {
 726+    TIMEVALUE("str");
 727+  }, ERRORS.VALUE_ERROR);
 728+  catchAndAssertEquals(function() {
 729+    TIMEVALUE([]);
 730+  }, ERRORS.REF_ERROR);
 731+});
 732 
 733-// Test TIMEVALUE
 734-assertEquals(TIMEVALUE("1969-7-6"), 0);
 735-assertEquals(TIMEVALUE("1969-7-6 8am"), 0.3333333333333333);
 736-assertEquals(TIMEVALUE("1969-7-28 8:10"), 0.3402777777777778);
 737-assertEquals(TIMEVALUE("2100-7-6 8:10pm"), 0.8402777777777778);
 738-assertEquals(TIMEVALUE("1999-1-1 8:10000pm"), 0.7777777777777778);
 739-assertEquals(TIMEVALUE("2012/1/1 28:10000"), 0.1111111111111111);
 740-assertEquals(TIMEVALUE("2012/1/1 14:23232:9999991"), 0.45730324074074075);
 741-assertEquals(TIMEVALUE(["2012/1/1 8:10"]), 0.3402777777777778);
 742-assertEquals(TIMEVALUE("2012/1/1 11:21222:2111pm"), 0.7202662037037038);
 743-assertEquals(TIMEVALUE("2012/1/1 11:21222:2111am"), 0.2202662037037037);
 744-assertEquals(TIMEVALUE("8am"), 0.3333333333333333);
 745-assertEquals(TIMEVALUE("8:10"), 0.3402777777777778);
 746-assertEquals(TIMEVALUE("8:10pm"), 0.8402777777777778);
 747-assertEquals(TIMEVALUE("8:10000pm"), 0.7777777777777778);
 748-assertEquals(TIMEVALUE("28:10000"), 0.1111111111111111);
 749-assertEquals(TIMEVALUE("14:23232:9999991"), 0.45730324074074075);
 750-assertEquals(TIMEVALUE(["8:10"]), 0.3402777777777778);
 751-assertEquals(TIMEVALUE("11:21222:2111pm"), 0.7202662037037038);
 752-assertEquals(TIMEVALUE("11:21222:2111am"), 0.2202662037037037);
 753-catchAndAssertEquals(function() {
 754-  TIMEVALUE("8:10", 5);
 755-}, ERRORS.NA_ERROR);
 756-catchAndAssertEquals(function() {
 757-  TIMEVALUE();
 758-}, ERRORS.NA_ERROR);
 759-catchAndAssertEquals(function() {
 760-  TIMEVALUE("str");
 761-}, ERRORS.VALUE_ERROR);
 762-catchAndAssertEquals(function() {
 763-  TIMEVALUE([]);
 764-}, ERRORS.REF_ERROR);
 765 
 766+test("YEARFRAC", function(){
 767+  assertEquals(YEARFRAC(1, 1461, 2), 4.055555555555555);
 768+  assertEquals(YEARFRAC(0, 365, 0), 1);
 769+  assertEquals(YEARFRAC(0, 365, 1), 1);
 770+  assertEquals(YEARFRAC(0, 365, 2), 1.0138888888888888);
 771+  assertEquals(YEARFRAC(0, 365, 3), 1);
 772+  assertEquals(YEARFRAC(0, 365, 4), 1);
 773+  assertEquals(YEARFRAC(0, 1000, 0), 2.738888888888889);
 774+  assertEquals(YEARFRAC(0, 1000, 1), 2.73972602739726);
 775+  assertEquals(YEARFRAC(0, 1000, 2), 2.7777777777777777);
 776+  assertEquals(YEARFRAC(0, 1000, 3), 2.73972602739726);
 777+  assertEquals(YEARFRAC(0, 1000, 4), 2.738888888888889);
 778+  assertEquals(YEARFRAC(10000, 20000, 0), 27.375);
 779+  assertEquals(YEARFRAC(10000, 20000, 1), 27.378507871321013); // gs: 27.37808219, ms: 27.37850787
 780+  assertEquals(YEARFRAC(10000, 20000, 2), 27.77777777777778);
 781+  assertEquals(YEARFRAC(10000, 20000, 3), 27.397260273972602);
 782+  assertEquals(YEARFRAC(10000, 20000, 4), 27.375);
 783+  assertEquals(YEARFRAC(100000, 200000, 0), 273.7944444444444);
 784+  assertEquals(YEARFRAC(100000, 200000, 1), 273.7925747453729); // gs: 273.7917808, ms: 273.7925747
 785+  assertEquals(YEARFRAC(100000, 200000, 2), 277.77777777777777);
 786+  assertEquals(YEARFRAC(100000, 200000, 3), 273.972602739726);
 787+  assertEquals(YEARFRAC(100000, 200000, 4), 273.7944444444444);
 788+  assertEquals(YEARFRAC("1969-7-6", "1988-7-4", 0), 18.994444444444444);
 789+  assertEquals(YEARFRAC("1969-7-6", "1988-7-22", 0), 19.044444444444444);
 790+  assertEquals(YEARFRAC("1992-1-6", "2191-7-22", 0), 199.544444444444444);
 791+  assertEquals(YEARFRAC("1992-1-6", "2191-1-21", 0), 199.041666666666667);
 792+  assertEquals(YEARFRAC("1992-1-6", "2144-1-22", 0), 152.044444444444444);
 793+  assertEquals(YEARFRAC("1992-1-6", "1992-1-6", 0), 0);
 794+  assertEquals(YEARFRAC("1992-1-6", "1992-1-1", 0), 0.013888888888888888);
 795+  assertEquals(YEARFRAC("1992-1-6", "1993-1-6", 0), 1);
 796+  assertEquals(YEARFRAC("1969-7-6", "1988-7-4", 1), 18.99520876112252);
 797+  assertEquals(YEARFRAC("1969-7-6", "1988-7-22", 1), 19.044490075290895);
 798+  assertEquals(YEARFRAC("1992-1-6", "2191-7-22", 1), 199.54003477118098);
 799+  assertEquals(YEARFRAC("1992-1-6", "2191-1-21", 1), 199.04173910662706);
 800+  assertEquals(YEARFRAC("1992-1-6", "2144-1-22", 1), 152.04174793765546);
 801+  assertEquals(YEARFRAC("1992-1-6", "1992-1-6", 1), 0);
 802+  assertEquals(YEARFRAC("1992-1-6", "1992-1-1", 1), 0.01366120218579235);
 803+  assertEquals(YEARFRAC("1991-1-6", "1992-1-6", 1), 1);
 804+  assertEquals(YEARFRAC("1992-1-6", "1993-1-6", 1), 1);
 805+  assertEquals(YEARFRAC("1969-7-6", "1988-7-22", 2), 19.322222222222223);
 806+  assertEquals(YEARFRAC("1992-1-6", "2191-7-22", 2), 202.44722222222222);
 807+  assertEquals(YEARFRAC("1992-1-6", "2191-1-21", 2), 201.94166666666666);
 808+  assertEquals(YEARFRAC("1992-1-6", "2144-1-22", 2), 154.25833333333333);
 809+  assertEquals(YEARFRAC("1992-1-6", "1992-1-6", 2), 0);
 810+  assertEquals(YEARFRAC("1992-1-6", "1992-1-1", 2), 0.013888888888888888);
 811+  assertEquals(YEARFRAC("1991-1-6", "1992-1-6", 2), 1.0138888888888888);
 812+  assertEquals(YEARFRAC("1992-1-6", "1993-1-6", 2), 1.0166666666666666);
 813+  assertEquals(YEARFRAC("1969-7-6", "1988-7-22", 3), 19.057534246575344);
 814+  assertEquals(YEARFRAC("1992-1-6", "2191-7-22", 3), 199.67397260273972);
 815+  assertEquals(YEARFRAC("1992-1-6", "2191-1-21", 3), 199.17534246575343);
 816+  assertEquals(YEARFRAC("1992-1-6", "2144-1-22", 3), 152.14520547945204);
 817+  assertEquals(YEARFRAC("1992-1-6", "1992-1-6", 3), 0);
 818+  assertEquals(YEARFRAC("1992-1-6", "1992-1-1", 3), 0.0136986301369863);
 819+  assertEquals(YEARFRAC("1991-1-6", "1992-1-6", 3), 1);
 820+  assertEquals(YEARFRAC("1992-1-6", "1993-1-6", 3), 1.0027397260273974);
 821+  assertEquals(YEARFRAC("1969-7-6", "1988-7-22", 4), 19.044444444444444);
 822+  assertEquals(YEARFRAC("1992-1-6", "2191-7-22", 4), 199.54444444444445);
 823+  assertEquals(YEARFRAC("1992-1-6", "2191-1-21", 4), 199.04166666666666);
 824+  assertEquals(YEARFRAC("1992-1-6", "2144-1-22", 4), 152.04444444444445);
 825+  assertEquals(YEARFRAC("1992-1-6", "1992-1-6", 4), 0);
 826+  assertEquals(YEARFRAC("1992-1-6", "1992-1-1", 4), 0.013888888888888888);
 827+  assertEquals(YEARFRAC("1991-1-6", "1992-1-6", 4), 1);
 828+  assertEquals(YEARFRAC("1992-1-6", "1993-1-6", 4), 1);
 829+  assertEquals(YEARFRAC("1969-7-6", "1988-7-4", 2), 19.272222222222222);
 830+  assertEquals(YEARFRAC("1969-7-6", "1988-7-4", 3), 19.008219178082193);
 831+  assertEquals(YEARFRAC("1969-7-6", "1988-7-4", 4), 18.994444444444444);
 832+  assertEquals(YEARFRAC(["1992-1-6", []], ["1993-1-6", "str"], [4]), 1);
 833+  catchAndAssertEquals(function() {
 834+    YEARFRAC("1996-6-19", "1992-6-19", 5);
 835+  }, ERRORS.NUM_ERROR);
 836+  catchAndAssertEquals(function() {
 837+    YEARFRAC();
 838+  }, ERRORS.NA_ERROR);
 839+  catchAndAssertEquals(function() {
 840+    YEARFRAC("1992-6-19", "1995-6-19", 1, 0);
 841+  }, ERRORS.NA_ERROR);
 842+  catchAndAssertEquals(function() {
 843+    YEARFRAC("str", "1995-6-19", 1);
 844+  }, ERRORS.VALUE_ERROR);
 845+  catchAndAssertEquals(function() {
 846+    YEARFRAC([], "1995-6-19", 1);
 847+  }, ERRORS.REF_ERROR);
 848+});
 849 
 850 
 851-// Test YEARFRAC
 852-assertEquals(YEARFRAC(1, 1461, 2), 4.055555555555555);
 853-assertEquals(YEARFRAC(0, 365, 0), 1);
 854-assertEquals(YEARFRAC(0, 365, 1), 1);
 855-assertEquals(YEARFRAC(0, 365, 2), 1.0138888888888888);
 856-assertEquals(YEARFRAC(0, 365, 3), 1);
 857-assertEquals(YEARFRAC(0, 365, 4), 1);
 858-assertEquals(YEARFRAC(0, 1000, 0), 2.738888888888889);
 859-assertEquals(YEARFRAC(0, 1000, 1), 2.73972602739726);
 860-assertEquals(YEARFRAC(0, 1000, 2), 2.7777777777777777);
 861-assertEquals(YEARFRAC(0, 1000, 3), 2.73972602739726);
 862-assertEquals(YEARFRAC(0, 1000, 4), 2.738888888888889);
 863-assertEquals(YEARFRAC(10000, 20000, 0), 27.375);
 864-assertEquals(YEARFRAC(10000, 20000, 1), 27.378507871321013); // gs: 27.37808219, ms: 27.37850787
 865-assertEquals(YEARFRAC(10000, 20000, 2), 27.77777777777778);
 866-assertEquals(YEARFRAC(10000, 20000, 3), 27.397260273972602);
 867-assertEquals(YEARFRAC(10000, 20000, 4), 27.375);
 868-assertEquals(YEARFRAC(100000, 200000, 0), 273.7944444444444);
 869-assertEquals(YEARFRAC(100000, 200000, 1), 273.7925747453729); // gs: 273.7917808, ms: 273.7925747
 870-assertEquals(YEARFRAC(100000, 200000, 2), 277.77777777777777);
 871-assertEquals(YEARFRAC(100000, 200000, 3), 273.972602739726);
 872-assertEquals(YEARFRAC(100000, 200000, 4), 273.7944444444444);
 873-assertEquals(YEARFRAC("1969-7-6", "1988-7-4", 0), 18.994444444444444);
 874-assertEquals(YEARFRAC("1969-7-6", "1988-7-22", 0), 19.044444444444444);
 875-assertEquals(YEARFRAC("1992-1-6", "2191-7-22", 0), 199.544444444444444);
 876-assertEquals(YEARFRAC("1992-1-6", "2191-1-21", 0), 199.041666666666667);
 877-assertEquals(YEARFRAC("1992-1-6", "2144-1-22", 0), 152.044444444444444);
 878-assertEquals(YEARFRAC("1992-1-6", "1992-1-6", 0), 0);
 879-assertEquals(YEARFRAC("1992-1-6", "1992-1-1", 0), 0.013888888888888888);
 880-assertEquals(YEARFRAC("1992-1-6", "1993-1-6", 0), 1);
 881-assertEquals(YEARFRAC("1969-7-6", "1988-7-4", 1), 18.99520876112252);
 882-assertEquals(YEARFRAC("1969-7-6", "1988-7-22", 1), 19.044490075290895);
 883-assertEquals(YEARFRAC("1992-1-6", "2191-7-22", 1), 199.54003477118098);
 884-assertEquals(YEARFRAC("1992-1-6", "2191-1-21", 1), 199.04173910662706);
 885-assertEquals(YEARFRAC("1992-1-6", "2144-1-22", 1), 152.04174793765546);
 886-assertEquals(YEARFRAC("1992-1-6", "1992-1-6", 1), 0);
 887-assertEquals(YEARFRAC("1992-1-6", "1992-1-1", 1), 0.01366120218579235);
 888-assertEquals(YEARFRAC("1991-1-6", "1992-1-6", 1), 1);
 889-assertEquals(YEARFRAC("1992-1-6", "1993-1-6", 1), 1);
 890-assertEquals(YEARFRAC("1969-7-6", "1988-7-22", 2), 19.322222222222223);
 891-assertEquals(YEARFRAC("1992-1-6", "2191-7-22", 2), 202.44722222222222);
 892-assertEquals(YEARFRAC("1992-1-6", "2191-1-21", 2), 201.94166666666666);
 893-assertEquals(YEARFRAC("1992-1-6", "2144-1-22", 2), 154.25833333333333);
 894-assertEquals(YEARFRAC("1992-1-6", "1992-1-6", 2), 0);
 895-assertEquals(YEARFRAC("1992-1-6", "1992-1-1", 2), 0.013888888888888888);
 896-assertEquals(YEARFRAC("1991-1-6", "1992-1-6", 2), 1.0138888888888888);
 897-assertEquals(YEARFRAC("1992-1-6", "1993-1-6", 2), 1.0166666666666666);
 898-assertEquals(YEARFRAC("1969-7-6", "1988-7-22", 3), 19.057534246575344);
 899-assertEquals(YEARFRAC("1992-1-6", "2191-7-22", 3), 199.67397260273972);
 900-assertEquals(YEARFRAC("1992-1-6", "2191-1-21", 3), 199.17534246575343);
 901-assertEquals(YEARFRAC("1992-1-6", "2144-1-22", 3), 152.14520547945204);
 902-assertEquals(YEARFRAC("1992-1-6", "1992-1-6", 3), 0);
 903-assertEquals(YEARFRAC("1992-1-6", "1992-1-1", 3), 0.0136986301369863);
 904-assertEquals(YEARFRAC("1991-1-6", "1992-1-6", 3), 1);
 905-assertEquals(YEARFRAC("1992-1-6", "1993-1-6", 3), 1.0027397260273974);
 906-assertEquals(YEARFRAC("1969-7-6", "1988-7-22", 4), 19.044444444444444);
 907-assertEquals(YEARFRAC("1992-1-6", "2191-7-22", 4), 199.54444444444445);
 908-assertEquals(YEARFRAC("1992-1-6", "2191-1-21", 4), 199.04166666666666);
 909-assertEquals(YEARFRAC("1992-1-6", "2144-1-22", 4), 152.04444444444445);
 910-assertEquals(YEARFRAC("1992-1-6", "1992-1-6", 4), 0);
 911-assertEquals(YEARFRAC("1992-1-6", "1992-1-1", 4), 0.013888888888888888);
 912-assertEquals(YEARFRAC("1991-1-6", "1992-1-6", 4), 1);
 913-assertEquals(YEARFRAC("1992-1-6", "1993-1-6", 4), 1);
 914-assertEquals(YEARFRAC("1969-7-6", "1988-7-4", 2), 19.272222222222222);
 915-assertEquals(YEARFRAC("1969-7-6", "1988-7-4", 3), 19.008219178082193);
 916-assertEquals(YEARFRAC("1969-7-6", "1988-7-4", 4), 18.994444444444444);
 917-assertEquals(YEARFRAC(["1992-1-6", []], ["1993-1-6", "str"], [4]), 1);
 918-catchAndAssertEquals(function() {
 919-  YEARFRAC("1996-6-19", "1992-6-19", 5);
 920-}, ERRORS.NUM_ERROR);
 921-catchAndAssertEquals(function() {
 922-  YEARFRAC();
 923-}, ERRORS.NA_ERROR);
 924-catchAndAssertEquals(function() {
 925-  YEARFRAC("1992-6-19", "1995-6-19", 1, 0);
 926-}, ERRORS.NA_ERROR);
 927-catchAndAssertEquals(function() {
 928-  YEARFRAC("str", "1995-6-19", 1);
 929-}, ERRORS.VALUE_ERROR);
 930-catchAndAssertEquals(function() {
 931-  YEARFRAC([], "1995-6-19", 1);
 932-}, ERRORS.REF_ERROR);
 933+test("DATEDIF", function(){
 934+  assertEquals(DATEDIF("1992-6-19", "1996-6-19", "Y"), 4);
 935+  assertEquals(DATEDIF("1992-6-19", "1996-6-0", "Y"), 3);
 936+  assertEquals(DATEDIF("1992-6-19", "1992-8-1", "Y"), 0);
 937+  assertEquals(DATEDIF("1992-6-19", "2199-8-1", "Y"), 207);
 938+  assertEquals(DATEDIF("1992-6-19", "1996-6-19", "M"), 48);
 939+  assertEquals(DATEDIF("1992-6-19", "1996-6-1", "M"), 47);
 940+  assertEquals(DATEDIF("1992-6-19", "1992-8-1", "M"), 1);
 941+  assertEquals(DATEDIF("1992-6-19", "2199-8-1", "M"), 2485);
 942+  assertEquals(DATEDIF("1992-6-19", "1996-6-19", "D"), 1461);
 943+  assertEquals(DATEDIF("1992-6-19", "1996-6-1", "D"), 1443);
 944+  assertEquals(DATEDIF("1992-6-19", "1992-8-1", "D"), 43);
 945+  assertEquals(DATEDIF("1992-6-19", "2199-8-1", "D"), 75648);
 946+  assertEquals(DATEDIF("1992-6-19", "2199-8-1", "MD"), 13);
 947+  assertEquals(DATEDIF("1992-6-19", "2012-7-22", "MD"), 3);
 948+  assertEquals(DATEDIF("1992-6-19", "1993-8-1", "MD"), 13);
 949+  assertEquals(DATEDIF("1992-6-19", "2000-1-19", "MD"), 0);
 950+  assertEquals(DATEDIF("1992-6-19", "2000-1-20", "MD"), 1);
 951+  assertEquals(DATEDIF("1992-6-19", "2000-1-21", "MD"), 2);
 952+  assertEquals(DATEDIF("1992-6-19", "2000-1-22", "MD"), 3);
 953+  assertEquals(DATEDIF("1992-6-19", "2000-1-23", "MD"), 4);
 954+  assertEquals(DATEDIF("1992-6-19", "2000-1-24", "MD"), 5);
 955+  assertEquals(DATEDIF("1992-6-19", "2000-1-25", "MD"), 6);
 956+  assertEquals(DATEDIF("1992-6-20", "2000-1-25", "MD"), 5);
 957+  assertEquals(DATEDIF("1992-6-19", "2199-8-1", "YM"), 1);
 958+  assertEquals(DATEDIF("1992-6-19", "2012-7-22", "YM"), 1);
 959+  assertEquals(DATEDIF("1992-6-19", "1993-8-1", "YM"), 1);
 960+  assertEquals(DATEDIF("1992-6-19", "2000-1-19", "YM"), 7);
 961+  assertEquals(DATEDIF("1992-6-19", "2000-1-20", "YM"), 7);
 962+  assertEquals(DATEDIF("1992-6-19", "2000-1-21", "YM"), 7);
 963+  assertEquals(DATEDIF("1992-6-19", "2000-1-22", "YM"), 7);
 964+  assertEquals(DATEDIF("1992-6-19", "2000-1-23", "YM"), 7);
 965+  assertEquals(DATEDIF("1992-6-19", "2000-1-24", "YM"), 7);
 966+  assertEquals(DATEDIF("1992-6-19", "2000-1-25", "YM"), 7);
 967+  assertEquals(DATEDIF("1992-6-20", "2000-1-25", "YM"), 7);
 968+  assertEquals(DATEDIF("1992-6-19", "1992-6-19", "YM"), 0);
 969+  assertEquals(DATEDIF("1992-6-19", "1992-7-19", "YM"), 1);
 970+  assertEquals(DATEDIF("1992-6-19", "1993-7-19", "YM"), 1);
 971+  assertEquals(DATEDIF("1992-6-19", "1993-6-19", "YM"), 0);
 972+  assertEquals(DATEDIF("1992-6-19", "2199-8-1", "YD"), 43);
 973+  assertEquals(DATEDIF("1992-6-19", "2012-7-22", "YD"), 33);
 974+  assertEquals(DATEDIF("1992-6-19", "1993-8-1", "YD"), 43);
 975+  assertEquals(DATEDIF("1992-6-19", "2000-1-19", "YD"), 214);
 976+  assertEquals(DATEDIF("1992-6-19", "2000-1-20", "YD"), 215);
 977+  assertEquals(DATEDIF("1992-6-19", "2000-1-21", "YD"), 216);
 978+  assertEquals(DATEDIF("1992-6-19", "2000-1-22", "YD"), 217);
 979+  assertEquals(DATEDIF("1992-6-19", "2000-1-23", "YD"), 218);
 980+  assertEquals(DATEDIF("1992-6-19", "2000-1-24", "YD"), 219);
 981+  assertEquals(DATEDIF("1992-6-19", "2000-1-25", "YD"), 220);
 982+  assertEquals(DATEDIF("1992-6-19", "1992-6-19", "YD"), 0);
 983+  assertEquals(DATEDIF("1992-6-19", "1992-7-19", "YD"), 30);
 984+  assertEquals(DATEDIF("1992-6-19", "1993-7-19", "YD"), 30);
 985+  assertEquals(DATEDIF("1992-6-19", "1993-6-19", "YD"), 0);
 986+  assertEquals(DATEDIF("1992-6-19", "1993-6-19", "yd"), 0);
 987+  assertEquals(DATEDIF(["1992-6-19", "str"], ["1993-6-19", []], ["yd"]), 0);
 988+  catchAndAssertEquals(function() {
 989+    DATEDIF("1996-6-19", "1992-6-19", "Y");
 990+  }, ERRORS.NUM_ERROR);
 991+  catchAndAssertEquals(function() {
 992+    DATEDIF("1992-6-19", "1995-6-19", "Y ");
 993+  }, ERRORS.NUM_ERROR);
 994+  catchAndAssertEquals(function() {
 995+    DATEDIF("1992-6-19", "1995-6-19", "mm");
 996+  }, ERRORS.NUM_ERROR);
 997+  catchAndAssertEquals(function() {
 998+    DATEDIF();
 999+  }, ERRORS.NA_ERROR);
1000+  catchAndAssertEquals(function() {
1001+    DATEDIF("1992-6-19", "1995-6-19", "mm", 0);
1002+  }, ERRORS.NA_ERROR);
1003+  catchAndAssertEquals(function() {
1004+    DATEDIF("str", "1995-6-19", "mm");
1005+  }, ERRORS.VALUE_ERROR);
1006+  catchAndAssertEquals(function() {
1007+    DATEDIF([], "1995-6-19", "mm");
1008+  }, ERRORS.REF_ERROR);
1009+});
1010 
1011 
1012-// Test DATEDIF
1013-assertEquals(DATEDIF("1992-6-19", "1996-6-19", "Y"), 4);
1014-assertEquals(DATEDIF("1992-6-19", "1996-6-0", "Y"), 3);
1015-assertEquals(DATEDIF("1992-6-19", "1992-8-1", "Y"), 0);
1016-assertEquals(DATEDIF("1992-6-19", "2199-8-1", "Y"), 207);
1017-assertEquals(DATEDIF("1992-6-19", "1996-6-19", "M"), 48);
1018-assertEquals(DATEDIF("1992-6-19", "1996-6-1", "M"), 47);
1019-assertEquals(DATEDIF("1992-6-19", "1992-8-1", "M"), 1);
1020-assertEquals(DATEDIF("1992-6-19", "2199-8-1", "M"), 2485);
1021-assertEquals(DATEDIF("1992-6-19", "1996-6-19", "D"), 1461);
1022-assertEquals(DATEDIF("1992-6-19", "1996-6-1", "D"), 1443);
1023-assertEquals(DATEDIF("1992-6-19", "1992-8-1", "D"), 43);
1024-assertEquals(DATEDIF("1992-6-19", "2199-8-1", "D"), 75648);
1025-assertEquals(DATEDIF("1992-6-19", "2199-8-1", "MD"), 13);
1026-assertEquals(DATEDIF("1992-6-19", "2012-7-22", "MD"), 3);
1027-assertEquals(DATEDIF("1992-6-19", "1993-8-1", "MD"), 13);
1028-assertEquals(DATEDIF("1992-6-19", "2000-1-19", "MD"), 0);
1029-assertEquals(DATEDIF("1992-6-19", "2000-1-20", "MD"), 1);
1030-assertEquals(DATEDIF("1992-6-19", "2000-1-21", "MD"), 2);
1031-assertEquals(DATEDIF("1992-6-19", "2000-1-22", "MD"), 3);
1032-assertEquals(DATEDIF("1992-6-19", "2000-1-23", "MD"), 4);
1033-assertEquals(DATEDIF("1992-6-19", "2000-1-24", "MD"), 5);
1034-assertEquals(DATEDIF("1992-6-19", "2000-1-25", "MD"), 6);
1035-assertEquals(DATEDIF("1992-6-20", "2000-1-25", "MD"), 5);
1036-assertEquals(DATEDIF("1992-6-19", "2199-8-1", "YM"), 1);
1037-assertEquals(DATEDIF("1992-6-19", "2012-7-22", "YM"), 1);
1038-assertEquals(DATEDIF("1992-6-19", "1993-8-1", "YM"), 1);
1039-assertEquals(DATEDIF("1992-6-19", "2000-1-19", "YM"), 7);
1040-assertEquals(DATEDIF("1992-6-19", "2000-1-20", "YM"), 7);
1041-assertEquals(DATEDIF("1992-6-19", "2000-1-21", "YM"), 7);
1042-assertEquals(DATEDIF("1992-6-19", "2000-1-22", "YM"), 7);
1043-assertEquals(DATEDIF("1992-6-19", "2000-1-23", "YM"), 7);
1044-assertEquals(DATEDIF("1992-6-19", "2000-1-24", "YM"), 7);
1045-assertEquals(DATEDIF("1992-6-19", "2000-1-25", "YM"), 7);
1046-assertEquals(DATEDIF("1992-6-20", "2000-1-25", "YM"), 7);
1047-assertEquals(DATEDIF("1992-6-19", "1992-6-19", "YM"), 0);
1048-assertEquals(DATEDIF("1992-6-19", "1992-7-19", "YM"), 1);
1049-assertEquals(DATEDIF("1992-6-19", "1993-7-19", "YM"), 1);
1050-assertEquals(DATEDIF("1992-6-19", "1993-6-19", "YM"), 0);
1051-assertEquals(DATEDIF("1992-6-19", "2199-8-1", "YD"), 43);
1052-assertEquals(DATEDIF("1992-6-19", "2012-7-22", "YD"), 33);
1053-assertEquals(DATEDIF("1992-6-19", "1993-8-1", "YD"), 43);
1054-assertEquals(DATEDIF("1992-6-19", "2000-1-19", "YD"), 214);
1055-assertEquals(DATEDIF("1992-6-19", "2000-1-20", "YD"), 215);
1056-assertEquals(DATEDIF("1992-6-19", "2000-1-21", "YD"), 216);
1057-assertEquals(DATEDIF("1992-6-19", "2000-1-22", "YD"), 217);
1058-assertEquals(DATEDIF("1992-6-19", "2000-1-23", "YD"), 218);
1059-assertEquals(DATEDIF("1992-6-19", "2000-1-24", "YD"), 219);
1060-assertEquals(DATEDIF("1992-6-19", "2000-1-25", "YD"), 220);
1061-assertEquals(DATEDIF("1992-6-19", "1992-6-19", "YD"), 0);
1062-assertEquals(DATEDIF("1992-6-19", "1992-7-19", "YD"), 30);
1063-assertEquals(DATEDIF("1992-6-19", "1993-7-19", "YD"), 30);
1064-assertEquals(DATEDIF("1992-6-19", "1993-6-19", "YD"), 0);
1065-assertEquals(DATEDIF("1992-6-19", "1993-6-19", "yd"), 0);
1066-assertEquals(DATEDIF(["1992-6-19", "str"], ["1993-6-19", []], ["yd"]), 0);
1067-catchAndAssertEquals(function() {
1068-  DATEDIF("1996-6-19", "1992-6-19", "Y");
1069-}, ERRORS.NUM_ERROR);
1070-catchAndAssertEquals(function() {
1071-  DATEDIF("1992-6-19", "1995-6-19", "Y ");
1072-}, ERRORS.NUM_ERROR);
1073-catchAndAssertEquals(function() {
1074-  DATEDIF("1992-6-19", "1995-6-19", "mm");
1075-}, ERRORS.NUM_ERROR);
1076-catchAndAssertEquals(function() {
1077-  DATEDIF();
1078-}, ERRORS.NA_ERROR);
1079-catchAndAssertEquals(function() {
1080-  DATEDIF("1992-6-19", "1995-6-19", "mm", 0);
1081-}, ERRORS.NA_ERROR);
1082-catchAndAssertEquals(function() {
1083-  DATEDIF("str", "1995-6-19", "mm");
1084-}, ERRORS.VALUE_ERROR);
1085-catchAndAssertEquals(function() {
1086-  DATEDIF([], "1995-6-19", "mm");
1087-}, ERRORS.REF_ERROR);
1088+test("WEEKNUM", function(){
1089+  assertEquals(WEEKNUM(DATE(1992, 6, 19)), 25);
1090+  assertEquals(WEEKNUM(DATE(1992, 6, 20)), 25);
1091+  assertEquals(WEEKNUM(DATE(1992, 6, 21)), 26);
1092+  assertEquals(WEEKNUM(0), 52);
1093+  assertEquals(WEEKNUM(false), 52);
1094+  assertEquals(WEEKNUM(1), 53);
1095+  assertEquals(WEEKNUM(true), 53);
1096+  assertEquals(WEEKNUM(2), 1);
1097+  assertEquals(WEEKNUM(3), 1);
1098+  assertEquals(WEEKNUM(4), 1);
1099+  assertEquals(WEEKNUM(5), 1);
1100+  assertEquals(WEEKNUM(6), 1);
1101+  assertEquals(WEEKNUM(7), 1);
1102+  assertEquals(WEEKNUM(8), 2);
1103+  assertEquals(WEEKNUM(9), 2);
1104+  assertEquals(WEEKNUM(10), 2);
1105+  assertEquals(WEEKNUM(11), 2);
1106+  assertEquals(WEEKNUM(12), 2);
1107+  assertEquals(WEEKNUM(13), 2);
1108+  assertEquals(WEEKNUM(14), 2);
1109+  assertEquals(WEEKNUM(15), 3);
1110+  assertEquals(WEEKNUM(16), 3);
1111+  assertEquals(WEEKNUM(17), 3);
1112+  assertEquals(WEEKNUM(18), 3);
1113+  assertEquals(WEEKNUM(23734), 52);
1114+  assertEquals(WEEKNUM(23735), 52);
1115+  assertEquals(WEEKNUM(23736), 52);
1116+  assertEquals(WEEKNUM(23737), 52);
1117+  assertEquals(WEEKNUM(23738), 53);
1118+  assertEquals(WEEKNUM(23739), 53);
1119+  assertEquals(WEEKNUM(23740), 53);
1120+  assertEquals(WEEKNUM(23741), 53);
1121+  assertEquals(WEEKNUM(23742), 53);
1122+  assertEquals(WEEKNUM(23743), 1);
1123+  assertEquals(WEEKNUM(23744), 1);
1124+  assertEquals(WEEKNUM(23745), 2);
1125+  assertEquals(WEEKNUM(23746), 2);
1126+  assertEquals(WEEKNUM(23747), 2);
1127+  assertEquals(WEEKNUM(23748), 2);
1128+  assertEquals(WEEKNUM(23749), 2);
1129+  assertEquals(WEEKNUM(23750), 2);
1130+  assertEquals(WEEKNUM(23751), 2);
1131+  assertEquals(WEEKNUM(23752), 3);
1132+  // type=2
1133+  assertEquals(WEEKNUM(23737, 2), 52);
1134+  assertEquals(WEEKNUM(23738, 2), 52);
1135+  assertEquals(WEEKNUM(23739, 2), 53);
1136+  assertEquals(WEEKNUM(23740, 2), 53);
1137+  assertEquals(WEEKNUM(23741, 2), 53);
1138+  assertEquals(WEEKNUM(23742, 2), 53);
1139+  assertEquals(WEEKNUM(23743, 2), 1);
1140+  assertEquals(WEEKNUM(23744, 2), 1);
1141+  assertEquals(WEEKNUM(23745, 2), 1);
1142+  assertEquals(WEEKNUM(23746, 2), 2);
1143+  assertEquals(WEEKNUM(23747, 2), 2);
1144+  assertEquals(WEEKNUM(23748, 2), 2);
1145+  assertEquals(WEEKNUM(23749, 2), 2);
1146+  assertEquals(WEEKNUM(23750, 2), 2);
1147+  assertEquals(WEEKNUM(23751, 2), 2);
1148+  assertEquals(WEEKNUM(23752, 2), 2);
1149+  assertEquals(WEEKNUM(23753, 2), 3);
1150+  assertEquals(WEEKNUM(23754, 2), 3);
1151+  assertEquals(WEEKNUM(23755, 2), 3);
1152+  assertEquals(WEEKNUM(23756, 2), 3);
1153+  assertEquals(WEEKNUM(23757, 2), 3);
1154+  assertEquals(WEEKNUM(23758, 2), 3);
1155+  assertEquals(WEEKNUM(23759, 2), 3);
1156+  assertEquals(WEEKNUM(23760, 2), 4);
1157+  //type=11
1158+  assertEquals(WEEKNUM(23737, 11), 52);
1159+  assertEquals(WEEKNUM(23738, 11), 52);
1160+  assertEquals(WEEKNUM(23739, 11), 53);
1161+  assertEquals(WEEKNUM(23740, 11), 53);
1162+  assertEquals(WEEKNUM(23741, 11), 53);
1163+  assertEquals(WEEKNUM(23742, 11), 53);
1164+  assertEquals(WEEKNUM(23743, 11), 1);
1165+  assertEquals(WEEKNUM(23744, 11), 1);
1166+  assertEquals(WEEKNUM(23745, 11), 1);
1167+  assertEquals(WEEKNUM(23746, 11), 2);
1168+  assertEquals(WEEKNUM(23747, 11), 2);
1169+  assertEquals(WEEKNUM(23748, 11), 2);
1170+  assertEquals(WEEKNUM(23749, 11), 2);
1171+  assertEquals(WEEKNUM(23750, 11), 2);
1172+  assertEquals(WEEKNUM(23751, 11), 2);
1173+  assertEquals(WEEKNUM(23752, 11), 2);
1174+  assertEquals(WEEKNUM(23753, 11), 3);
1175+  assertEquals(WEEKNUM(23754, 11), 3);
1176+  assertEquals(WEEKNUM(23755, 11), 3);
1177+  assertEquals(WEEKNUM(23756, 11), 3);
1178+  assertEquals(WEEKNUM(23757, 11), 3);
1179+  assertEquals(WEEKNUM(23758, 11), 3);
1180+  assertEquals(WEEKNUM(23759, 11), 3);
1181+  assertEquals(WEEKNUM(23760, 11), 4);
1182+  //type=12
1183+  assertEquals(WEEKNUM(23737, 12), 52);
1184+  assertEquals(WEEKNUM(23738, 12), 52);
1185+  assertEquals(WEEKNUM(23739, 12), 52);
1186+  assertEquals(WEEKNUM(23740, 12), 53);
1187+  assertEquals(WEEKNUM(23741, 12), 53);
1188+  assertEquals(WEEKNUM(23742, 12), 53);
1189+  assertEquals(WEEKNUM(23743, 12), 1);
1190+  assertEquals(WEEKNUM(23744, 12), 1);
1191+  assertEquals(WEEKNUM(23745, 12), 1);
1192+  assertEquals(WEEKNUM(23746, 12), 1);
1193+  assertEquals(WEEKNUM(23747, 12), 2);
1194+  assertEquals(WEEKNUM(23748, 12), 2);
1195+  assertEquals(WEEKNUM(23749, 12), 2);
1196+  assertEquals(WEEKNUM(23750, 12), 2);
1197+  assertEquals(WEEKNUM(23751, 12), 2);
1198+  assertEquals(WEEKNUM(23752, 12), 2);
1199+  assertEquals(WEEKNUM(23753, 12), 2);
1200+  assertEquals(WEEKNUM(23754, 12), 3);
1201+  assertEquals(WEEKNUM(23755, 12), 3);
1202+  assertEquals(WEEKNUM(23756, 12), 3);
1203+  assertEquals(WEEKNUM(23757, 12), 3);
1204+  assertEquals(WEEKNUM(23758, 12), 3);
1205+  assertEquals(WEEKNUM(23759, 12), 3);
1206+  assertEquals(WEEKNUM(23760, 12), 3);
1207+  //type=13
1208+  assertEquals(WEEKNUM(23737, 13), 52);
1209+  assertEquals(WEEKNUM(23738, 13), 52);
1210+  assertEquals(WEEKNUM(23739, 13), 52);
1211+  assertEquals(WEEKNUM(23740, 13), 52);
1212+  assertEquals(WEEKNUM(23741, 13), 53);
1213+  assertEquals(WEEKNUM(23742, 13), 53);
1214+  assertEquals(WEEKNUM(23743, 13), 1);
1215+  assertEquals(WEEKNUM(23744, 13), 1);
1216+  assertEquals(WEEKNUM(23745, 13), 1);
1217+  assertEquals(WEEKNUM(23746, 13), 1);
1218+  assertEquals(WEEKNUM(23747, 13), 1);
1219+  assertEquals(WEEKNUM(23748, 13), 2);
1220+  assertEquals(WEEKNUM(23749, 13), 2);
1221+  assertEquals(WEEKNUM(23750, 13), 2);
1222+  assertEquals(WEEKNUM(23751, 13), 2);
1223+  assertEquals(WEEKNUM(23752, 13), 2);
1224+  assertEquals(WEEKNUM(23753, 13), 2);
1225+  assertEquals(WEEKNUM(23754, 13), 2);
1226+  assertEquals(WEEKNUM(23755, 13), 3);
1227+  assertEquals(WEEKNUM(23756, 13), 3);
1228+  assertEquals(WEEKNUM(23757, 13), 3);
1229+  assertEquals(WEEKNUM(23758, 13), 3);
1230+  assertEquals(WEEKNUM(23759, 13), 3);
1231+  assertEquals(WEEKNUM(23760, 13), 3);
1232+  //type=14
1233+  assertEquals(WEEKNUM(23734, 14), 52);
1234+  assertEquals(WEEKNUM(23735, 14), 53);
1235+  assertEquals(WEEKNUM(23736, 14), 53);
1236+  assertEquals(WEEKNUM(23737, 14), 53);
1237+  assertEquals(WEEKNUM(23738, 14), 53);
1238+  assertEquals(WEEKNUM(23739, 14), 53);
1239+  assertEquals(WEEKNUM(23740, 14), 53);
1240+  assertEquals(WEEKNUM(23741, 14), 53);
1241+  assertEquals(WEEKNUM(23742, 14), 54);
1242+  assertEquals(WEEKNUM(23743, 14), 1);
1243+  assertEquals(WEEKNUM(23744, 14), 1);
1244+  assertEquals(WEEKNUM(23745, 14), 1);
1245+  assertEquals(WEEKNUM(23746, 14), 1);
1246+  assertEquals(WEEKNUM(23747, 14), 1);
1247+  assertEquals(WEEKNUM(23748, 14), 1);
1248+  assertEquals(WEEKNUM(23749, 14), 2);
1249+  assertEquals(WEEKNUM(23750, 14), 2);
1250+  assertEquals(WEEKNUM(23751, 14), 2);
1251+  assertEquals(WEEKNUM(23752, 14), 2);
1252+  assertEquals(WEEKNUM(23753, 14), 2);
1253+  assertEquals(WEEKNUM(23754, 14), 2);
1254+  assertEquals(WEEKNUM(23755, 14), 2);
1255+  assertEquals(WEEKNUM(23756, 14), 3);
1256+  assertEquals(WEEKNUM(23757, 14), 3);
1257+  assertEquals(WEEKNUM(23758, 14), 3);
1258+  assertEquals(WEEKNUM(23759, 14), 3);
1259+  assertEquals(WEEKNUM(23760, 14), 3);
1260+  //type=14 again
1261+  assertEquals(WEEKNUM(355, 14), 52);
1262+  assertEquals(WEEKNUM(356, 14), 52);
1263+  assertEquals(WEEKNUM(357, 14), 52);
1264+  assertEquals(WEEKNUM(358, 14), 52);
1265+  assertEquals(WEEKNUM(359, 14), 52);
1266+  assertEquals(WEEKNUM(360, 14), 52);
1267+  assertEquals(WEEKNUM(361, 14), 52);
1268+  assertEquals(WEEKNUM(362, 14), 53);
1269+  assertEquals(WEEKNUM(363, 14), 53);
1270+  assertEquals(WEEKNUM(364, 14), 53);
1271+  assertEquals(WEEKNUM(365, 14), 53);
1272+  assertEquals(WEEKNUM(366, 14), 53);
1273+  assertEquals(WEEKNUM(367, 14), 1);
1274+  assertEquals(WEEKNUM(368, 14), 1);
1275+  assertEquals(WEEKNUM(369, 14), 2);
1276+  assertEquals(WEEKNUM(370, 14), 2);
1277+  assertEquals(WEEKNUM(371, 14), 2);
1278+  assertEquals(WEEKNUM(372, 14), 2);
1279+  assertEquals(WEEKNUM(373, 14), 2);
1280+  assertEquals(WEEKNUM(374, 14), 2);
1281+  assertEquals(WEEKNUM(375, 14), 2);
1282+  assertEquals(WEEKNUM(376, 14), 3);
1283+  assertEquals(WEEKNUM(377, 14), 3);
1284+  assertEquals(WEEKNUM(378, 14), 3);
1285+  assertEquals(WEEKNUM(379, 14), 3);
1286+  assertEquals(WEEKNUM(380, 14), 3);
1287+  assertEquals(WEEKNUM(381, 14), 3);
1288+  //type=14 again
1289+  assertEquals(WEEKNUM(730, 14), 53);
1290+  assertEquals(WEEKNUM(731, 14), 53);
1291+  assertEquals(WEEKNUM(732, 14), 1);
1292+  assertEquals(WEEKNUM(733, 14), 2);
1293+  assertEquals(WEEKNUM(734, 14), 2);
1294+  assertEquals(WEEKNUM(735, 14), 2);
1295+  assertEquals(WEEKNUM(736, 14), 2);
1296+  assertEquals(WEEKNUM(737, 14), 2);
1297+  assertEquals(WEEKNUM(738, 14), 2);
1298+  assertEquals(WEEKNUM(739, 14), 2);
1299+  assertEquals(WEEKNUM(740, 14), 3);
1300+  assertEquals(WEEKNUM(741, 14), 3);
1301+  assertEquals(WEEKNUM(742, 14), 3);
1302+  assertEquals(WEEKNUM(743, 14), 3);
1303+  assertEquals(WEEKNUM(744, 14), 3);
1304+  assertEquals(WEEKNUM(745, 14), 3);
1305+  assertEquals(WEEKNUM(746, 14), 3);
1306+  //type=15
1307+  assertEquals(WEEKNUM(23734, 15), 52);
1308+  assertEquals(WEEKNUM(23735, 15), 52);
1309+  assertEquals(WEEKNUM(23736, 15), 53);
1310+  assertEquals(WEEKNUM(23737, 15), 53);
1311+  assertEquals(WEEKNUM(23738, 15), 53);
1312+  assertEquals(WEEKNUM(23739, 15), 53);
1313+  assertEquals(WEEKNUM(23740, 15), 53);
1314+  assertEquals(WEEKNUM(23741, 15), 53);
1315+  assertEquals(WEEKNUM(23742, 15), 53);
1316+  assertEquals(WEEKNUM(23743, 15), 1);
1317+  assertEquals(WEEKNUM(23744, 15), 1);
1318+  assertEquals(WEEKNUM(23745, 15), 1);
1319+  assertEquals(WEEKNUM(23746, 15), 1);
1320+  assertEquals(WEEKNUM(23747, 15), 1);
1321+  assertEquals(WEEKNUM(23748, 15), 1);
1322+  assertEquals(WEEKNUM(23749, 15), 1);
1323+  assertEquals(WEEKNUM(23750, 15), 2);
1324+  assertEquals(WEEKNUM(23751, 15), 2);
1325+  assertEquals(WEEKNUM(23752, 15), 2);
1326+  assertEquals(WEEKNUM(23753, 15), 2);
1327+  assertEquals(WEEKNUM(23754, 15), 2);
1328+  assertEquals(WEEKNUM(23755, 15), 2);
1329+  assertEquals(WEEKNUM(23756, 15), 2);
1330+  assertEquals(WEEKNUM(23757, 15), 3);
1331+  assertEquals(WEEKNUM(23758, 15), 3);
1332+  assertEquals(WEEKNUM(23759, 15), 3);
1333+  assertEquals(WEEKNUM(23760, 15), 3);
1334+  //type=15 again
1335+  assertEquals(WEEKNUM(355, 15), 51);
1336+  assertEquals(WEEKNUM(356, 15), 52);
1337+  assertEquals(WEEKNUM(357, 15), 52);
1338+  assertEquals(WEEKNUM(358, 15), 52);
1339+  assertEquals(WEEKNUM(359, 15), 52);
1340+  assertEquals(WEEKNUM(360, 15), 52);
1341+  assertEquals(WEEKNUM(361, 15), 52);
1342+  assertEquals(WEEKNUM(362, 15), 52);
1343+  assertEquals(WEEKNUM(363, 15), 53);
1344+  assertEquals(WEEKNUM(364, 15), 53);
1345+  assertEquals(WEEKNUM(365, 15), 53);
1346+  assertEquals(WEEKNUM(366, 15), 53);
1347+  assertEquals(WEEKNUM(367, 15), 1);
1348+  assertEquals(WEEKNUM(368, 15), 1);
1349+  assertEquals(WEEKNUM(369, 15), 1);
1350+  assertEquals(WEEKNUM(370, 15), 2);
1351+  assertEquals(WEEKNUM(371, 15), 2);
1352+  assertEquals(WEEKNUM(372, 15), 2);
1353+  assertEquals(WEEKNUM(373, 15), 2);
1354+  assertEquals(WEEKNUM(374, 15), 2);
1355+  assertEquals(WEEKNUM(375, 15), 2);
1356+  assertEquals(WEEKNUM(376, 15), 2);
1357+  assertEquals(WEEKNUM(377, 15), 3);
1358+  assertEquals(WEEKNUM(378, 15), 3);
1359+  assertEquals(WEEKNUM(379, 15), 3);
1360+  assertEquals(WEEKNUM(380, 15), 3);
1361+  assertEquals(WEEKNUM(381, 15), 3);
1362+  //type=15 again
1363+  assertEquals(WEEKNUM(730, 15), 53);
1364+  assertEquals(WEEKNUM(731, 15), 53);
1365+  assertEquals(WEEKNUM(732, 15), 1);
1366+  assertEquals(WEEKNUM(733, 15), 1);
1367+  assertEquals(WEEKNUM(734, 15), 2);
1368+  assertEquals(WEEKNUM(735, 15), 2);
1369+  assertEquals(WEEKNUM(736, 15), 2);
1370+  assertEquals(WEEKNUM(737, 15), 2);
1371+  assertEquals(WEEKNUM(738, 15), 2);
1372+  assertEquals(WEEKNUM(739, 15), 2);
1373+  assertEquals(WEEKNUM(740, 15), 2);
1374+  assertEquals(WEEKNUM(741, 15), 3);
1375+  assertEquals(WEEKNUM(742, 15), 3);
1376+  assertEquals(WEEKNUM(743, 15), 3);
1377+  assertEquals(WEEKNUM(744, 15), 3);
1378+  assertEquals(WEEKNUM(745, 15), 3);
1379+  assertEquals(WEEKNUM(746, 15), 3);
1380+  //type=16
1381+  assertEquals(WEEKNUM(23734, 16), 52);
1382+  assertEquals(WEEKNUM(23735, 16), 52);
1383+  assertEquals(WEEKNUM(23736, 16), 52);
1384+  assertEquals(WEEKNUM(23737, 16), 53);
1385+  assertEquals(WEEKNUM(23738, 16), 53);
1386+  assertEquals(WEEKNUM(23739, 16), 53);
1387+  assertEquals(WEEKNUM(23740, 16), 53);
1388+  assertEquals(WEEKNUM(23741, 16), 53);
1389+  assertEquals(WEEKNUM(23742, 16), 53);
1390+  assertEquals(WEEKNUM(23743, 16), 1);
1391+  assertEquals(WEEKNUM(23744, 16), 2);
1392+  assertEquals(WEEKNUM(23745, 16), 2);
1393+  assertEquals(WEEKNUM(23746, 16), 2);
1394+  assertEquals(WEEKNUM(23747, 16), 2);
1395+  assertEquals(WEEKNUM(23748, 16), 2);
1396+  assertEquals(WEEKNUM(23749, 16), 2);
1397+  assertEquals(WEEKNUM(23750, 16), 2);
1398+  assertEquals(WEEKNUM(23751, 16), 3);
1399+  assertEquals(WEEKNUM(23752, 16), 3);
1400+  assertEquals(WEEKNUM(23753, 16), 3);
1401+  assertEquals(WEEKNUM(23754, 16), 3);
1402+  assertEquals(WEEKNUM(23755, 16), 3);
1403+  assertEquals(WEEKNUM(23756, 16), 3);
1404+  assertEquals(WEEKNUM(23757, 16), 3);
1405+  assertEquals(WEEKNUM(23758, 16), 4);
1406+  assertEquals(WEEKNUM(23759, 16), 4);
1407+  assertEquals(WEEKNUM(23760, 16), 4);
1408+  // //type=16 again
1409+  assertEquals(WEEKNUM(355, 16), 51);
1410+  assertEquals(WEEKNUM(356, 16), 51);
1411+  assertEquals(WEEKNUM(357, 16), 52);
1412+  assertEquals(WEEKNUM(358, 16), 52);
1413+  assertEquals(WEEKNUM(359, 16), 52);
1414+  assertEquals(WEEKNUM(360, 16), 52);
1415+  assertEquals(WEEKNUM(361, 16), 52);
1416+  assertEquals(WEEKNUM(362, 16), 52);
1417+  assertEquals(WEEKNUM(363, 16), 52);
1418+  assertEquals(WEEKNUM(364, 16), 53);
1419+  assertEquals(WEEKNUM(365, 16), 53);
1420+  assertEquals(WEEKNUM(366, 16), 53);
1421+  assertEquals(WEEKNUM(367, 16), 1);
1422+  assertEquals(WEEKNUM(368, 16), 1);
1423+  assertEquals(WEEKNUM(369, 16), 1);
1424+  assertEquals(WEEKNUM(370, 16), 1);
1425+  assertEquals(WEEKNUM(371, 16), 2);
1426+  assertEquals(WEEKNUM(372, 16), 2);
1427+  assertEquals(WEEKNUM(373, 16), 2);
1428+  assertEquals(WEEKNUM(374, 16), 2);
1429+  assertEquals(WEEKNUM(375, 16), 2);
1430+  assertEquals(WEEKNUM(376, 16), 2);
1431+  assertEquals(WEEKNUM(377, 16), 2);
1432+  assertEquals(WEEKNUM(378, 16), 3);
1433+  assertEquals(WEEKNUM(379, 16), 3);
1434+  assertEquals(WEEKNUM(380, 16), 3);
1435+  assertEquals(WEEKNUM(381, 16), 3);
1436+  //type=16 again
1437+  assertEquals(WEEKNUM(730, 16), 53);
1438+  assertEquals(WEEKNUM(731, 16), 53);
1439+  assertEquals(WEEKNUM(732, 16), 1);
1440+  assertEquals(WEEKNUM(733, 16), 1);
1441+  assertEquals(WEEKNUM(734, 16), 1);
1442+  assertEquals(WEEKNUM(735, 16), 2);
1443+  assertEquals(WEEKNUM(736, 16), 2);
1444+  assertEquals(WEEKNUM(737, 16), 2);
1445+  assertEquals(WEEKNUM(738, 16), 2);
1446+  assertEquals(WEEKNUM(739, 16), 2);
1447+  assertEquals(WEEKNUM(740, 16), 2);
1448+  assertEquals(WEEKNUM(741, 16), 2);
1449+  assertEquals(WEEKNUM(742, 16), 3);
1450+  assertEquals(WEEKNUM(743, 16), 3);
1451+  assertEquals(WEEKNUM(744, 16), 3);
1452+  assertEquals(WEEKNUM(745, 16), 3);
1453+  assertEquals(WEEKNUM(746, 16), 3);
1454+  //type=17
1455+  assertEquals(WEEKNUM(23734, 17), 52);
1456+  assertEquals(WEEKNUM(23735, 17), 52);
1457+  assertEquals(WEEKNUM(23736, 17), 52);
1458+  assertEquals(WEEKNUM(23737, 17), 52);
1459+  assertEquals(WEEKNUM(23738, 17), 53);
1460+  assertEquals(WEEKNUM(23739, 17), 53);
1461+  assertEquals(WEEKNUM(23740, 17), 53);
1462+  assertEquals(WEEKNUM(23741, 17), 53);
1463+  assertEquals(WEEKNUM(23742, 17), 53);
1464+  assertEquals(WEEKNUM(23743, 17), 1);
1465+  assertEquals(WEEKNUM(23744, 17), 1);
1466+  assertEquals(WEEKNUM(23745, 17), 2);
1467+  assertEquals(WEEKNUM(23746, 17), 2);
1468+  assertEquals(WEEKNUM(23747, 17), 2);
1469+  assertEquals(WEEKNUM(23748, 17), 2);
1470+  assertEquals(WEEKNUM(23749, 17), 2);
1471+  assertEquals(WEEKNUM(23750, 17), 2);
1472+  assertEquals(WEEKNUM(23751, 17), 2);
1473+  assertEquals(WEEKNUM(23752, 17), 3);
1474+  assertEquals(WEEKNUM(23753, 17), 3);
1475+  assertEquals(WEEKNUM(23754, 17), 3);
1476+  assertEquals(WEEKNUM(23755, 17), 3);
1477+  assertEquals(WEEKNUM(23756, 17), 3);
1478+  assertEquals(WEEKNUM(23757, 17), 3);
1479+  assertEquals(WEEKNUM(23758, 17), 3);
1480+  assertEquals(WEEKNUM(23759, 17), 4);
1481+  assertEquals(WEEKNUM(23760, 17), 4);
1482+  // //type=17 again
1483+  assertEquals(WEEKNUM(355, 17), 51);
1484+  assertEquals(WEEKNUM(356, 17), 51);
1485+  assertEquals(WEEKNUM(357, 17), 51);
1486+  assertEquals(WEEKNUM(358, 17), 52);
1487+  assertEquals(WEEKNUM(359, 17), 52);
1488+  assertEquals(WEEKNUM(360, 17), 52);
1489+  assertEquals(WEEKNUM(361, 17), 52);
1490+  assertEquals(WEEKNUM(362, 17), 52);
1491+  assertEquals(WEEKNUM(363, 17), 52);
1492+  assertEquals(WEEKNUM(364, 17), 52);
1493+  assertEquals(WEEKNUM(365, 17), 53);
1494+  assertEquals(WEEKNUM(366, 17), 53);
1495+  assertEquals(WEEKNUM(367, 17), 1);
1496+  assertEquals(WEEKNUM(368, 17), 1);
1497+  assertEquals(WEEKNUM(369, 17), 1);
1498+  assertEquals(WEEKNUM(370, 17), 1);
1499+  assertEquals(WEEKNUM(371, 17), 1);
1500+  assertEquals(WEEKNUM(372, 17), 2);
1501+  assertEquals(WEEKNUM(373, 17), 2);
1502+  assertEquals(WEEKNUM(374, 17), 2);
1503+  assertEquals(WEEKNUM(375, 17), 2);
1504+  assertEquals(WEEKNUM(376, 17), 2);
1505+  assertEquals(WEEKNUM(377, 17), 2);
1506+  assertEquals(WEEKNUM(378, 17), 2);
1507+  assertEquals(WEEKNUM(379, 17), 3);
1508+  assertEquals(WEEKNUM(380, 17), 3);
1509+  assertEquals(WEEKNUM(381, 17), 3);
1510+  //type=17 again
1511+  assertEquals(WEEKNUM(730, 17), 53);
1512+  assertEquals(WEEKNUM(731, 17), 53);
1513+  assertEquals(WEEKNUM(732, 17), 1);
1514+  assertEquals(WEEKNUM(733, 17), 1);
1515+  assertEquals(WEEKNUM(734, 17), 1);
1516+  assertEquals(WEEKNUM(735, 17), 1);
1517+  assertEquals(WEEKNUM(736, 17), 2);
1518+  assertEquals(WEEKNUM(737, 17), 2);
1519+  assertEquals(WEEKNUM(738, 17), 2);
1520+  assertEquals(WEEKNUM(739, 17), 2);
1521+  assertEquals(WEEKNUM(740, 17), 2);
1522+  assertEquals(WEEKNUM(741, 17), 2);
1523+  assertEquals(WEEKNUM(742, 17), 2);
1524+  assertEquals(WEEKNUM(743, 17), 3);
1525+  assertEquals(WEEKNUM(744, 17), 3);
1526+  assertEquals(WEEKNUM(745, 17), 3);
1527+  assertEquals(WEEKNUM(746, 17), 3);
1528+  //type=21
1529+  assertEquals(WEEKNUM(23730, 21), 51);
1530+  assertEquals(WEEKNUM(23731, 21), 51);
1531+  assertEquals(WEEKNUM(23732, 21), 52);
1532+  assertEquals(WEEKNUM(23733, 21), 52);
1533+  assertEquals(WEEKNUM(23734, 21), 52);
1534+  assertEquals(WEEKNUM(23735, 21), 52);
1535+  assertEquals(WEEKNUM(23736, 21), 52);
1536+  assertEquals(WEEKNUM(23737, 21), 52);
1537+  assertEquals(WEEKNUM(23738, 21), 52);
1538+  assertEquals(WEEKNUM(23739, 21), 53);
1539+  assertEquals(WEEKNUM(23740, 21), 53);
1540+  assertEquals(WEEKNUM(23741, 21), 53);
1541+  assertEquals(WEEKNUM(23742, 21), 53);
1542+  assertEquals(WEEKNUM(23743, 21), 53);
1543+  assertEquals(WEEKNUM(23744, 21), 53);
1544+  assertEquals(WEEKNUM(23745, 21), 53);
1545+  assertEquals(WEEKNUM(23746, 21), 1);
1546+  assertEquals(WEEKNUM(23747, 21), 1);
1547+  assertEquals(WEEKNUM(23748, 21), 1);
1548+  assertEquals(WEEKNUM(23749, 21), 1);
1549+  assertEquals(WEEKNUM(23750, 21), 1);
1550+  assertEquals(WEEKNUM(23751, 21), 1);
1551+  assertEquals(WEEKNUM(23752, 21), 1);
1552+  assertEquals(WEEKNUM(23753, 21), 2);
1553+  assertEquals(WEEKNUM(23754, 21), 2);
1554+  assertEquals(WEEKNUM(23755, 21), 2);
1555+  assertEquals(WEEKNUM(23756, 21), 2);
1556+  assertEquals(WEEKNUM(23757, 21), 2);
1557+  assertEquals(WEEKNUM(23758, 21), 2);
1558+  assertEquals(WEEKNUM(23759, 21), 2);
1559+  assertEquals(WEEKNUM(23760, 21), 3);
1560+  // //type=21 again
1561+  assertEquals(WEEKNUM(355, 21), 51);
1562+  assertEquals(WEEKNUM(356, 21), 51);
1563+  assertEquals(WEEKNUM(357, 21), 51);
1564+  assertEquals(WEEKNUM(358, 21), 51);
1565+  assertEquals(WEEKNUM(359, 21), 52);
1566+  assertEquals(WEEKNUM(360, 21), 52);
1567+  assertEquals(WEEKNUM(361, 21), 52);
1568+  assertEquals(WEEKNUM(362, 21), 52);
1569+  assertEquals(WEEKNUM(363, 21), 52);
1570+  assertEquals(WEEKNUM(364, 21), 52);
1571+  assertEquals(WEEKNUM(365, 21), 52);
1572+  assertEquals(WEEKNUM(366, 21), 1);
1573+  assertEquals(WEEKNUM(367, 21), 1);
1574+  assertEquals(WEEKNUM(368, 21), 1);
1575+  assertEquals(WEEKNUM(369, 21), 1);
1576+  assertEquals(WEEKNUM(370, 21), 1);
1577+  assertEquals(WEEKNUM(371, 21), 1);
1578+  assertEquals(WEEKNUM(372, 21), 1);
1579+  assertEquals(WEEKNUM(373, 21), 2);
1580+  assertEquals(WEEKNUM(374, 21), 2);
1581+  assertEquals(WEEKNUM(375, 21), 2);
1582+  assertEquals(WEEKNUM(376, 21), 2);
1583+  assertEquals(WEEKNUM(377, 21), 2);
1584+  assertEquals(WEEKNUM(378, 21), 2);
1585+  assertEquals(WEEKNUM(379, 21), 2);
1586+  assertEquals(WEEKNUM(380, 21), 3);
1587+  assertEquals(WEEKNUM(381, 21), 3);
1588+  // //type=21 again
1589+  assertEquals(WEEKNUM(728, 21), 52);
1590+  assertEquals(WEEKNUM(729, 21), 52);
1591+  assertEquals(WEEKNUM(730, 21), 1);
1592+  assertEquals(WEEKNUM(731, 21), 1);
1593+  assertEquals(WEEKNUM(732, 21), 1);
1594+  assertEquals(WEEKNUM(733, 21), 1);
1595+  assertEquals(WEEKNUM(734, 21), 1);
1596+  assertEquals(WEEKNUM(735, 21), 1);
1597+  assertEquals(WEEKNUM(736, 21), 1);
1598+  assertEquals(WEEKNUM(737, 21), 2);
1599+  assertEquals(WEEKNUM(738, 21), 2);
1600+  assertEquals(WEEKNUM(739, 21), 2);
1601+  assertEquals(WEEKNUM(740, 21), 2);
1602+  assertEquals(WEEKNUM(741, 21), 2);
1603+  assertEquals(WEEKNUM(742, 21), 2);
1604+  assertEquals(WEEKNUM(743, 21), 2);
1605+  assertEquals(WEEKNUM(744, 21), 3);
1606+  assertEquals(WEEKNUM(745, 21), 3);
1607+  assertEquals(WEEKNUM(746, 21), 3);
1608+  catchAndAssertEquals(function() {
1609+    WEEKNUM();
1610+  }, ERRORS.NA_ERROR);
1611+  catchAndAssertEquals(function() {
1612+    WEEKNUM(213123, 1, 1);
1613+  }, ERRORS.NA_ERROR);
1614+  catchAndAssertEquals(function() {
1615+    WEEKNUM("str");
1616+  }, ERRORS.VALUE_ERROR);
1617+  catchAndAssertEquals(function() {
1618+    WEEKNUM([]);
1619+  }, ERRORS.REF_ERROR);
1620+  catchAndAssertEquals(function() {
1621+    WEEKNUM(-10);
1622+  }, ERRORS.NUM_ERROR);
1623+  catchAndAssertEquals(function() {
1624+    WEEKNUM(10, 4);
1625+  }, ERRORS.NUM_ERROR);
1626+  catchAndAssertEquals(function() {
1627+    WEEKNUM(10, 22);
1628+  }, ERRORS.NUM_ERROR);
1629+});
1630 
1631 
1632-// Test WEEKNUM
1633-assertEquals(WEEKNUM(DATE(1992, 6, 19)), 25);
1634-assertEquals(WEEKNUM(DATE(1992, 6, 20)), 25);
1635-assertEquals(WEEKNUM(DATE(1992, 6, 21)), 26);
1636-assertEquals(WEEKNUM(0), 52);
1637-assertEquals(WEEKNUM(false), 52);
1638-assertEquals(WEEKNUM(1), 53);
1639-assertEquals(WEEKNUM(true), 53);
1640-assertEquals(WEEKNUM(2), 1);
1641-assertEquals(WEEKNUM(3), 1);
1642-assertEquals(WEEKNUM(4), 1);
1643-assertEquals(WEEKNUM(5), 1);
1644-assertEquals(WEEKNUM(6), 1);
1645-assertEquals(WEEKNUM(7), 1);
1646-assertEquals(WEEKNUM(8), 2);
1647-assertEquals(WEEKNUM(9), 2);
1648-assertEquals(WEEKNUM(10), 2);
1649-assertEquals(WEEKNUM(11), 2);
1650-assertEquals(WEEKNUM(12), 2);
1651-assertEquals(WEEKNUM(13), 2);
1652-assertEquals(WEEKNUM(14), 2);
1653-assertEquals(WEEKNUM(15), 3);
1654-assertEquals(WEEKNUM(16), 3);
1655-assertEquals(WEEKNUM(17), 3);
1656-assertEquals(WEEKNUM(18), 3);
1657-assertEquals(WEEKNUM(23734), 52);
1658-assertEquals(WEEKNUM(23735), 52);
1659-assertEquals(WEEKNUM(23736), 52);
1660-assertEquals(WEEKNUM(23737), 52);
1661-assertEquals(WEEKNUM(23738), 53);
1662-assertEquals(WEEKNUM(23739), 53);
1663-assertEquals(WEEKNUM(23740), 53);
1664-assertEquals(WEEKNUM(23741), 53);
1665-assertEquals(WEEKNUM(23742), 53);
1666-assertEquals(WEEKNUM(23743), 1);
1667-assertEquals(WEEKNUM(23744), 1);
1668-assertEquals(WEEKNUM(23745), 2);
1669-assertEquals(WEEKNUM(23746), 2);
1670-assertEquals(WEEKNUM(23747), 2);
1671-assertEquals(WEEKNUM(23748), 2);
1672-assertEquals(WEEKNUM(23749), 2);
1673-assertEquals(WEEKNUM(23750), 2);
1674-assertEquals(WEEKNUM(23751), 2);
1675-assertEquals(WEEKNUM(23752), 3);
1676-// type=2
1677-assertEquals(WEEKNUM(23737, 2), 52);
1678-assertEquals(WEEKNUM(23738, 2), 52);
1679-assertEquals(WEEKNUM(23739, 2), 53);
1680-assertEquals(WEEKNUM(23740, 2), 53);
1681-assertEquals(WEEKNUM(23741, 2), 53);
1682-assertEquals(WEEKNUM(23742, 2), 53);
1683-assertEquals(WEEKNUM(23743, 2), 1);
1684-assertEquals(WEEKNUM(23744, 2), 1);
1685-assertEquals(WEEKNUM(23745, 2), 1);
1686-assertEquals(WEEKNUM(23746, 2), 2);
1687-assertEquals(WEEKNUM(23747, 2), 2);
1688-assertEquals(WEEKNUM(23748, 2), 2);
1689-assertEquals(WEEKNUM(23749, 2), 2);
1690-assertEquals(WEEKNUM(23750, 2), 2);
1691-assertEquals(WEEKNUM(23751, 2), 2);
1692-assertEquals(WEEKNUM(23752, 2), 2);
1693-assertEquals(WEEKNUM(23753, 2), 3);
1694-assertEquals(WEEKNUM(23754, 2), 3);
1695-assertEquals(WEEKNUM(23755, 2), 3);
1696-assertEquals(WEEKNUM(23756, 2), 3);
1697-assertEquals(WEEKNUM(23757, 2), 3);
1698-assertEquals(WEEKNUM(23758, 2), 3);
1699-assertEquals(WEEKNUM(23759, 2), 3);
1700-assertEquals(WEEKNUM(23760, 2), 4);
1701-//type=11
1702-assertEquals(WEEKNUM(23737, 11), 52);
1703-assertEquals(WEEKNUM(23738, 11), 52);
1704-assertEquals(WEEKNUM(23739, 11), 53);
1705-assertEquals(WEEKNUM(23740, 11), 53);
1706-assertEquals(WEEKNUM(23741, 11), 53);
1707-assertEquals(WEEKNUM(23742, 11), 53);
1708-assertEquals(WEEKNUM(23743, 11), 1);
1709-assertEquals(WEEKNUM(23744, 11), 1);
1710-assertEquals(WEEKNUM(23745, 11), 1);
1711-assertEquals(WEEKNUM(23746, 11), 2);
1712-assertEquals(WEEKNUM(23747, 11), 2);
1713-assertEquals(WEEKNUM(23748, 11), 2);
1714-assertEquals(WEEKNUM(23749, 11), 2);
1715-assertEquals(WEEKNUM(23750, 11), 2);
1716-assertEquals(WEEKNUM(23751, 11), 2);
1717-assertEquals(WEEKNUM(23752, 11), 2);
1718-assertEquals(WEEKNUM(23753, 11), 3);
1719-assertEquals(WEEKNUM(23754, 11), 3);
1720-assertEquals(WEEKNUM(23755, 11), 3);
1721-assertEquals(WEEKNUM(23756, 11), 3);
1722-assertEquals(WEEKNUM(23757, 11), 3);
1723-assertEquals(WEEKNUM(23758, 11), 3);
1724-assertEquals(WEEKNUM(23759, 11), 3);
1725-assertEquals(WEEKNUM(23760, 11), 4);
1726-//type=12
1727-assertEquals(WEEKNUM(23737, 12), 52);
1728-assertEquals(WEEKNUM(23738, 12), 52);
1729-assertEquals(WEEKNUM(23739, 12), 52);
1730-assertEquals(WEEKNUM(23740, 12), 53);
1731-assertEquals(WEEKNUM(23741, 12), 53);
1732-assertEquals(WEEKNUM(23742, 12), 53);
1733-assertEquals(WEEKNUM(23743, 12), 1);
1734-assertEquals(WEEKNUM(23744, 12), 1);
1735-assertEquals(WEEKNUM(23745, 12), 1);
1736-assertEquals(WEEKNUM(23746, 12), 1);
1737-assertEquals(WEEKNUM(23747, 12), 2);
1738-assertEquals(WEEKNUM(23748, 12), 2);
1739-assertEquals(WEEKNUM(23749, 12), 2);
1740-assertEquals(WEEKNUM(23750, 12), 2);
1741-assertEquals(WEEKNUM(23751, 12), 2);
1742-assertEquals(WEEKNUM(23752, 12), 2);
1743-assertEquals(WEEKNUM(23753, 12), 2);
1744-assertEquals(WEEKNUM(23754, 12), 3);
1745-assertEquals(WEEKNUM(23755, 12), 3);
1746-assertEquals(WEEKNUM(23756, 12), 3);
1747-assertEquals(WEEKNUM(23757, 12), 3);
1748-assertEquals(WEEKNUM(23758, 12), 3);
1749-assertEquals(WEEKNUM(23759, 12), 3);
1750-assertEquals(WEEKNUM(23760, 12), 3);
1751-//type=13
1752-assertEquals(WEEKNUM(23737, 13), 52);
1753-assertEquals(WEEKNUM(23738, 13), 52);
1754-assertEquals(WEEKNUM(23739, 13), 52);
1755-assertEquals(WEEKNUM(23740, 13), 52);
1756-assertEquals(WEEKNUM(23741, 13), 53);
1757-assertEquals(WEEKNUM(23742, 13), 53);
1758-assertEquals(WEEKNUM(23743, 13), 1);
1759-assertEquals(WEEKNUM(23744, 13), 1);
1760-assertEquals(WEEKNUM(23745, 13), 1);
1761-assertEquals(WEEKNUM(23746, 13), 1);
1762-assertEquals(WEEKNUM(23747, 13), 1);
1763-assertEquals(WEEKNUM(23748, 13), 2);
1764-assertEquals(WEEKNUM(23749, 13), 2);
1765-assertEquals(WEEKNUM(23750, 13), 2);
1766-assertEquals(WEEKNUM(23751, 13), 2);
1767-assertEquals(WEEKNUM(23752, 13), 2);
1768-assertEquals(WEEKNUM(23753, 13), 2);
1769-assertEquals(WEEKNUM(23754, 13), 2);
1770-assertEquals(WEEKNUM(23755, 13), 3);
1771-assertEquals(WEEKNUM(23756, 13), 3);
1772-assertEquals(WEEKNUM(23757, 13), 3);
1773-assertEquals(WEEKNUM(23758, 13), 3);
1774-assertEquals(WEEKNUM(23759, 13), 3);
1775-assertEquals(WEEKNUM(23760, 13), 3);
1776-//type=14
1777-assertEquals(WEEKNUM(23734, 14), 52);
1778-assertEquals(WEEKNUM(23735, 14), 53);
1779-assertEquals(WEEKNUM(23736, 14), 53);
1780-assertEquals(WEEKNUM(23737, 14), 53);
1781-assertEquals(WEEKNUM(23738, 14), 53);
1782-assertEquals(WEEKNUM(23739, 14), 53);
1783-assertEquals(WEEKNUM(23740, 14), 53);
1784-assertEquals(WEEKNUM(23741, 14), 53);
1785-assertEquals(WEEKNUM(23742, 14), 54);
1786-assertEquals(WEEKNUM(23743, 14), 1);
1787-assertEquals(WEEKNUM(23744, 14), 1);
1788-assertEquals(WEEKNUM(23745, 14), 1);
1789-assertEquals(WEEKNUM(23746, 14), 1);
1790-assertEquals(WEEKNUM(23747, 14), 1);
1791-assertEquals(WEEKNUM(23748, 14), 1);
1792-assertEquals(WEEKNUM(23749, 14), 2);
1793-assertEquals(WEEKNUM(23750, 14), 2);
1794-assertEquals(WEEKNUM(23751, 14), 2);
1795-assertEquals(WEEKNUM(23752, 14), 2);
1796-assertEquals(WEEKNUM(23753, 14), 2);
1797-assertEquals(WEEKNUM(23754, 14), 2);
1798-assertEquals(WEEKNUM(23755, 14), 2);
1799-assertEquals(WEEKNUM(23756, 14), 3);
1800-assertEquals(WEEKNUM(23757, 14), 3);
1801-assertEquals(WEEKNUM(23758, 14), 3);
1802-assertEquals(WEEKNUM(23759, 14), 3);
1803-assertEquals(WEEKNUM(23760, 14), 3);
1804-//type=14 again
1805-assertEquals(WEEKNUM(355, 14), 52);
1806-assertEquals(WEEKNUM(356, 14), 52);
1807-assertEquals(WEEKNUM(357, 14), 52);
1808-assertEquals(WEEKNUM(358, 14), 52);
1809-assertEquals(WEEKNUM(359, 14), 52);
1810-assertEquals(WEEKNUM(360, 14), 52);
1811-assertEquals(WEEKNUM(361, 14), 52);
1812-assertEquals(WEEKNUM(362, 14), 53);
1813-assertEquals(WEEKNUM(363, 14), 53);
1814-assertEquals(WEEKNUM(364, 14), 53);
1815-assertEquals(WEEKNUM(365, 14), 53);
1816-assertEquals(WEEKNUM(366, 14), 53);
1817-assertEquals(WEEKNUM(367, 14), 1);
1818-assertEquals(WEEKNUM(368, 14), 1);
1819-assertEquals(WEEKNUM(369, 14), 2);
1820-assertEquals(WEEKNUM(370, 14), 2);
1821-assertEquals(WEEKNUM(371, 14), 2);
1822-assertEquals(WEEKNUM(372, 14), 2);
1823-assertEquals(WEEKNUM(373, 14), 2);
1824-assertEquals(WEEKNUM(374, 14), 2);
1825-assertEquals(WEEKNUM(375, 14), 2);
1826-assertEquals(WEEKNUM(376, 14), 3);
1827-assertEquals(WEEKNUM(377, 14), 3);
1828-assertEquals(WEEKNUM(378, 14), 3);
1829-assertEquals(WEEKNUM(379, 14), 3);
1830-assertEquals(WEEKNUM(380, 14), 3);
1831-assertEquals(WEEKNUM(381, 14), 3);
1832-//type=14 again
1833-assertEquals(WEEKNUM(730, 14), 53);
1834-assertEquals(WEEKNUM(731, 14), 53);
1835-assertEquals(WEEKNUM(732, 14), 1);
1836-assertEquals(WEEKNUM(733, 14), 2);
1837-assertEquals(WEEKNUM(734, 14), 2);
1838-assertEquals(WEEKNUM(735, 14), 2);
1839-assertEquals(WEEKNUM(736, 14), 2);
1840-assertEquals(WEEKNUM(737, 14), 2);
1841-assertEquals(WEEKNUM(738, 14), 2);
1842-assertEquals(WEEKNUM(739, 14), 2);
1843-assertEquals(WEEKNUM(740, 14), 3);
1844-assertEquals(WEEKNUM(741, 14), 3);
1845-assertEquals(WEEKNUM(742, 14), 3);
1846-assertEquals(WEEKNUM(743, 14), 3);
1847-assertEquals(WEEKNUM(744, 14), 3);
1848-assertEquals(WEEKNUM(745, 14), 3);
1849-assertEquals(WEEKNUM(746, 14), 3);
1850-//type=15
1851-assertEquals(WEEKNUM(23734, 15), 52);
1852-assertEquals(WEEKNUM(23735, 15), 52);
1853-assertEquals(WEEKNUM(23736, 15), 53);
1854-assertEquals(WEEKNUM(23737, 15), 53);
1855-assertEquals(WEEKNUM(23738, 15), 53);
1856-assertEquals(WEEKNUM(23739, 15), 53);
1857-assertEquals(WEEKNUM(23740, 15), 53);
1858-assertEquals(WEEKNUM(23741, 15), 53);
1859-assertEquals(WEEKNUM(23742, 15), 53);
1860-assertEquals(WEEKNUM(23743, 15), 1);
1861-assertEquals(WEEKNUM(23744, 15), 1);
1862-assertEquals(WEEKNUM(23745, 15), 1);
1863-assertEquals(WEEKNUM(23746, 15), 1);
1864-assertEquals(WEEKNUM(23747, 15), 1);
1865-assertEquals(WEEKNUM(23748, 15), 1);
1866-assertEquals(WEEKNUM(23749, 15), 1);
1867-assertEquals(WEEKNUM(23750, 15), 2);
1868-assertEquals(WEEKNUM(23751, 15), 2);
1869-assertEquals(WEEKNUM(23752, 15), 2);
1870-assertEquals(WEEKNUM(23753, 15), 2);
1871-assertEquals(WEEKNUM(23754, 15), 2);
1872-assertEquals(WEEKNUM(23755, 15), 2);
1873-assertEquals(WEEKNUM(23756, 15), 2);
1874-assertEquals(WEEKNUM(23757, 15), 3);
1875-assertEquals(WEEKNUM(23758, 15), 3);
1876-assertEquals(WEEKNUM(23759, 15), 3);
1877-assertEquals(WEEKNUM(23760, 15), 3);
1878-//type=15 again
1879-assertEquals(WEEKNUM(355, 15), 51);
1880-assertEquals(WEEKNUM(356, 15), 52);
1881-assertEquals(WEEKNUM(357, 15), 52);
1882-assertEquals(WEEKNUM(358, 15), 52);
1883-assertEquals(WEEKNUM(359, 15), 52);
1884-assertEquals(WEEKNUM(360, 15), 52);
1885-assertEquals(WEEKNUM(361, 15), 52);
1886-assertEquals(WEEKNUM(362, 15), 52);
1887-assertEquals(WEEKNUM(363, 15), 53);
1888-assertEquals(WEEKNUM(364, 15), 53);
1889-assertEquals(WEEKNUM(365, 15), 53);
1890-assertEquals(WEEKNUM(366, 15), 53);
1891-assertEquals(WEEKNUM(367, 15), 1);
1892-assertEquals(WEEKNUM(368, 15), 1);
1893-assertEquals(WEEKNUM(369, 15), 1);
1894-assertEquals(WEEKNUM(370, 15), 2);
1895-assertEquals(WEEKNUM(371, 15), 2);
1896-assertEquals(WEEKNUM(372, 15), 2);
1897-assertEquals(WEEKNUM(373, 15), 2);
1898-assertEquals(WEEKNUM(374, 15), 2);
1899-assertEquals(WEEKNUM(375, 15), 2);
1900-assertEquals(WEEKNUM(376, 15), 2);
1901-assertEquals(WEEKNUM(377, 15), 3);
1902-assertEquals(WEEKNUM(378, 15), 3);
1903-assertEquals(WEEKNUM(379, 15), 3);
1904-assertEquals(WEEKNUM(380, 15), 3);
1905-assertEquals(WEEKNUM(381, 15), 3);
1906-//type=15 again
1907-assertEquals(WEEKNUM(730, 15), 53);
1908-assertEquals(WEEKNUM(731, 15), 53);
1909-assertEquals(WEEKNUM(732, 15), 1);
1910-assertEquals(WEEKNUM(733, 15), 1);
1911-assertEquals(WEEKNUM(734, 15), 2);
1912-assertEquals(WEEKNUM(735, 15), 2);
1913-assertEquals(WEEKNUM(736, 15), 2);
1914-assertEquals(WEEKNUM(737, 15), 2);
1915-assertEquals(WEEKNUM(738, 15), 2);
1916-assertEquals(WEEKNUM(739, 15), 2);
1917-assertEquals(WEEKNUM(740, 15), 2);
1918-assertEquals(WEEKNUM(741, 15), 3);
1919-assertEquals(WEEKNUM(742, 15), 3);
1920-assertEquals(WEEKNUM(743, 15), 3);
1921-assertEquals(WEEKNUM(744, 15), 3);
1922-assertEquals(WEEKNUM(745, 15), 3);
1923-assertEquals(WEEKNUM(746, 15), 3);
1924-//type=16
1925-assertEquals(WEEKNUM(23734, 16), 52);
1926-assertEquals(WEEKNUM(23735, 16), 52);
1927-assertEquals(WEEKNUM(23736, 16), 52);
1928-assertEquals(WEEKNUM(23737, 16), 53);
1929-assertEquals(WEEKNUM(23738, 16), 53);
1930-assertEquals(WEEKNUM(23739, 16), 53);
1931-assertEquals(WEEKNUM(23740, 16), 53);
1932-assertEquals(WEEKNUM(23741, 16), 53);
1933-assertEquals(WEEKNUM(23742, 16), 53);
1934-assertEquals(WEEKNUM(23743, 16), 1);
1935-assertEquals(WEEKNUM(23744, 16), 2);
1936-assertEquals(WEEKNUM(23745, 16), 2);
1937-assertEquals(WEEKNUM(23746, 16), 2);
1938-assertEquals(WEEKNUM(23747, 16), 2);
1939-assertEquals(WEEKNUM(23748, 16), 2);
1940-assertEquals(WEEKNUM(23749, 16), 2);
1941-assertEquals(WEEKNUM(23750, 16), 2);
1942-assertEquals(WEEKNUM(23751, 16), 3);
1943-assertEquals(WEEKNUM(23752, 16), 3);
1944-assertEquals(WEEKNUM(23753, 16), 3);
1945-assertEquals(WEEKNUM(23754, 16), 3);
1946-assertEquals(WEEKNUM(23755, 16), 3);
1947-assertEquals(WEEKNUM(23756, 16), 3);
1948-assertEquals(WEEKNUM(23757, 16), 3);
1949-assertEquals(WEEKNUM(23758, 16), 4);
1950-assertEquals(WEEKNUM(23759, 16), 4);
1951-assertEquals(WEEKNUM(23760, 16), 4);
1952-// //type=16 again
1953-assertEquals(WEEKNUM(355, 16), 51);
1954-assertEquals(WEEKNUM(356, 16), 51);
1955-assertEquals(WEEKNUM(357, 16), 52);
1956-assertEquals(WEEKNUM(358, 16), 52);
1957-assertEquals(WEEKNUM(359, 16), 52);
1958-assertEquals(WEEKNUM(360, 16), 52);
1959-assertEquals(WEEKNUM(361, 16), 52);
1960-assertEquals(WEEKNUM(362, 16), 52);
1961-assertEquals(WEEKNUM(363, 16), 52);
1962-assertEquals(WEEKNUM(364, 16), 53);
1963-assertEquals(WEEKNUM(365, 16), 53);
1964-assertEquals(WEEKNUM(366, 16), 53);
1965-assertEquals(WEEKNUM(367, 16), 1);
1966-assertEquals(WEEKNUM(368, 16), 1);
1967-assertEquals(WEEKNUM(369, 16), 1);
1968-assertEquals(WEEKNUM(370, 16), 1);
1969-assertEquals(WEEKNUM(371, 16), 2);
1970-assertEquals(WEEKNUM(372, 16), 2);
1971-assertEquals(WEEKNUM(373, 16), 2);
1972-assertEquals(WEEKNUM(374, 16), 2);
1973-assertEquals(WEEKNUM(375, 16), 2);
1974-assertEquals(WEEKNUM(376, 16), 2);
1975-assertEquals(WEEKNUM(377, 16), 2);
1976-assertEquals(WEEKNUM(378, 16), 3);
1977-assertEquals(WEEKNUM(379, 16), 3);
1978-assertEquals(WEEKNUM(380, 16), 3);
1979-assertEquals(WEEKNUM(381, 16), 3);
1980-//type=16 again
1981-assertEquals(WEEKNUM(730, 16), 53);
1982-assertEquals(WEEKNUM(731, 16), 53);
1983-assertEquals(WEEKNUM(732, 16), 1);
1984-assertEquals(WEEKNUM(733, 16), 1);
1985-assertEquals(WEEKNUM(734, 16), 1);
1986-assertEquals(WEEKNUM(735, 16), 2);
1987-assertEquals(WEEKNUM(736, 16), 2);
1988-assertEquals(WEEKNUM(737, 16), 2);
1989-assertEquals(WEEKNUM(738, 16), 2);
1990-assertEquals(WEEKNUM(739, 16), 2);
1991-assertEquals(WEEKNUM(740, 16), 2);
1992-assertEquals(WEEKNUM(741, 16), 2);
1993-assertEquals(WEEKNUM(742, 16), 3);
1994-assertEquals(WEEKNUM(743, 16), 3);
1995-assertEquals(WEEKNUM(744, 16), 3);
1996-assertEquals(WEEKNUM(745, 16), 3);
1997-assertEquals(WEEKNUM(746, 16), 3);
1998-//type=17
1999-assertEquals(WEEKNUM(23734, 17), 52);
2000-assertEquals(WEEKNUM(23735, 17), 52);
2001-assertEquals(WEEKNUM(23736, 17), 52);
2002-assertEquals(WEEKNUM(23737, 17), 52);
2003-assertEquals(WEEKNUM(23738, 17), 53);
2004-assertEquals(WEEKNUM(23739, 17), 53);
2005-assertEquals(WEEKNUM(23740, 17), 53);
2006-assertEquals(WEEKNUM(23741, 17), 53);
2007-assertEquals(WEEKNUM(23742, 17), 53);
2008-assertEquals(WEEKNUM(23743, 17), 1);
2009-assertEquals(WEEKNUM(23744, 17), 1);
2010-assertEquals(WEEKNUM(23745, 17), 2);
2011-assertEquals(WEEKNUM(23746, 17), 2);
2012-assertEquals(WEEKNUM(23747, 17), 2);
2013-assertEquals(WEEKNUM(23748, 17), 2);
2014-assertEquals(WEEKNUM(23749, 17), 2);
2015-assertEquals(WEEKNUM(23750, 17), 2);
2016-assertEquals(WEEKNUM(23751, 17), 2);
2017-assertEquals(WEEKNUM(23752, 17), 3);
2018-assertEquals(WEEKNUM(23753, 17), 3);
2019-assertEquals(WEEKNUM(23754, 17), 3);
2020-assertEquals(WEEKNUM(23755, 17), 3);
2021-assertEquals(WEEKNUM(23756, 17), 3);
2022-assertEquals(WEEKNUM(23757, 17), 3);
2023-assertEquals(WEEKNUM(23758, 17), 3);
2024-assertEquals(WEEKNUM(23759, 17), 4);
2025-assertEquals(WEEKNUM(23760, 17), 4);
2026-// //type=17 again
2027-assertEquals(WEEKNUM(355, 17), 51);
2028-assertEquals(WEEKNUM(356, 17), 51);
2029-assertEquals(WEEKNUM(357, 17), 51);
2030-assertEquals(WEEKNUM(358, 17), 52);
2031-assertEquals(WEEKNUM(359, 17), 52);
2032-assertEquals(WEEKNUM(360, 17), 52);
2033-assertEquals(WEEKNUM(361, 17), 52);
2034-assertEquals(WEEKNUM(362, 17), 52);
2035-assertEquals(WEEKNUM(363, 17), 52);
2036-assertEquals(WEEKNUM(364, 17), 52);
2037-assertEquals(WEEKNUM(365, 17), 53);
2038-assertEquals(WEEKNUM(366, 17), 53);
2039-assertEquals(WEEKNUM(367, 17), 1);
2040-assertEquals(WEEKNUM(368, 17), 1);
2041-assertEquals(WEEKNUM(369, 17), 1);
2042-assertEquals(WEEKNUM(370, 17), 1);
2043-assertEquals(WEEKNUM(371, 17), 1);
2044-assertEquals(WEEKNUM(372, 17), 2);
2045-assertEquals(WEEKNUM(373, 17), 2);
2046-assertEquals(WEEKNUM(374, 17), 2);
2047-assertEquals(WEEKNUM(375, 17), 2);
2048-assertEquals(WEEKNUM(376, 17), 2);
2049-assertEquals(WEEKNUM(377, 17), 2);
2050-assertEquals(WEEKNUM(378, 17), 2);
2051-assertEquals(WEEKNUM(379, 17), 3);
2052-assertEquals(WEEKNUM(380, 17), 3);
2053-assertEquals(WEEKNUM(381, 17), 3);
2054-//type=17 again
2055-assertEquals(WEEKNUM(730, 17), 53);
2056-assertEquals(WEEKNUM(731, 17), 53);
2057-assertEquals(WEEKNUM(732, 17), 1);
2058-assertEquals(WEEKNUM(733, 17), 1);
2059-assertEquals(WEEKNUM(734, 17), 1);
2060-assertEquals(WEEKNUM(735, 17), 1);
2061-assertEquals(WEEKNUM(736, 17), 2);
2062-assertEquals(WEEKNUM(737, 17), 2);
2063-assertEquals(WEEKNUM(738, 17), 2);
2064-assertEquals(WEEKNUM(739, 17), 2);
2065-assertEquals(WEEKNUM(740, 17), 2);
2066-assertEquals(WEEKNUM(741, 17), 2);
2067-assertEquals(WEEKNUM(742, 17), 2);
2068-assertEquals(WEEKNUM(743, 17), 3);
2069-assertEquals(WEEKNUM(744, 17), 3);
2070-assertEquals(WEEKNUM(745, 17), 3);
2071-assertEquals(WEEKNUM(746, 17), 3);
2072+test("WEEKDAY", function(){
2073+  assertEquals(WEEKDAY(DATE(1992, 6, 20)), 7);
2074+  assertEquals(WEEKDAY(DATE(1992, 6, 21)), 1);
2075+  assertEquals(WEEKDAY(DATE(1992, 6, 24)), 4);
2076+  assertEquals(WEEKDAY(DATE(1992, 6, 25)), 5);
2077+  assertEquals(WEEKDAY(1312211), 5);
2078+  assertEquals(WEEKDAY(1312212), 6);
2079+  assertEquals(WEEKDAY(1312213), 7);
2080+  assertEquals(WEEKDAY(0), 7);
2081+  assertEquals(WEEKDAY(false), 7);
2082+  assertEquals(WEEKDAY(1), 1);
2083+  assertEquals(WEEKDAY(true), 1);
2084+  assertEquals(WEEKDAY(40909, 1), 1);
2085+  assertEquals(WEEKDAY(40909, 2), 7);
2086+  assertEquals(WEEKDAY(40909, 3), 6);
2087+  assertEquals(WEEKDAY(411, 1), 5);
2088+  assertEquals(WEEKDAY(411, 2), 4);
2089+  assertEquals(WEEKDAY(411, 3), 3);
2090+  assertEquals(WEEKDAY(40909, 1), 1);
2091+  assertEquals(WEEKDAY(40910, 1), 2);
2092+  assertEquals(WEEKDAY(40911, 1), 3);
2093+  assertEquals(WEEKDAY(40912, 1), 4);
2094+  assertEquals(WEEKDAY(40913, 1), 5);
2095+  assertEquals(WEEKDAY(40914, 1), 6);
2096+  assertEquals(WEEKDAY(40915, 1), 7);
2097+  assertEquals(WEEKDAY(40916, 1), 1);
2098+  assertEquals(WEEKDAY(40909, 2), 7);
2099+  assertEquals(WEEKDAY(40910, 2), 1);
2100+  assertEquals(WEEKDAY(40911, 2), 2);
2101+  assertEquals(WEEKDAY(40912, 2), 3);
2102+  assertEquals(WEEKDAY(40913, 2), 4);
2103+  assertEquals(WEEKDAY(40914, 2), 5);
2104+  assertEquals(WEEKDAY(40915, 2), 6);
2105+  assertEquals(WEEKDAY(40916, 2), 7);
2106+  assertEquals(WEEKDAY(40909, 3), 6);
2107+  assertEquals(WEEKDAY(40910, 3), 0);
2108+  assertEquals(WEEKDAY(40911, 3), 1);
2109+  assertEquals(WEEKDAY(40912, 3), 2);
2110+  assertEquals(WEEKDAY(40913, 3), 3);
2111+  assertEquals(WEEKDAY(40914, 3), 4);
2112+  assertEquals(WEEKDAY(40915, 3), 5);
2113+  assertEquals(WEEKDAY(40916, 3), 6);
2114+  catchAndAssertEquals(function() {
2115+    WEEKDAY();
2116+  }, ERRORS.NA_ERROR);
2117+  catchAndAssertEquals(function() {
2118+    WEEKDAY(213123, 1, 1);
2119+  }, ERRORS.NA_ERROR);
2120+  catchAndAssertEquals(function() {
2121+    WEEKDAY("str");
2122+  }, ERRORS.VALUE_ERROR);
2123+  catchAndAssertEquals(function() {
2124+    WEEKDAY([]);
2125+  }, ERRORS.REF_ERROR);
2126+  catchAndAssertEquals(function() {
2127+    WEEKDAY(-10);
2128+  }, ERRORS.NUM_ERROR);
2129+  catchAndAssertEquals(function() {
2130+    WEEKDAY(10, 4);
2131+  }, ERRORS.NUM_ERROR);
2132+});
2133 
2134-//type=21
2135-assertEquals(WEEKNUM(23730, 21), 51);
2136-assertEquals(WEEKNUM(23731, 21), 51);
2137-assertEquals(WEEKNUM(23732, 21), 52);
2138-assertEquals(WEEKNUM(23733, 21), 52);
2139-assertEquals(WEEKNUM(23734, 21), 52);
2140-assertEquals(WEEKNUM(23735, 21), 52);
2141-assertEquals(WEEKNUM(23736, 21), 52);
2142-assertEquals(WEEKNUM(23737, 21), 52);
2143-assertEquals(WEEKNUM(23738, 21), 52);
2144-assertEquals(WEEKNUM(23739, 21), 53);
2145-assertEquals(WEEKNUM(23740, 21), 53);
2146-assertEquals(WEEKNUM(23741, 21), 53);
2147-assertEquals(WEEKNUM(23742, 21), 53);
2148-assertEquals(WEEKNUM(23743, 21), 53);
2149-assertEquals(WEEKNUM(23744, 21), 53);
2150-assertEquals(WEEKNUM(23745, 21), 53);
2151-assertEquals(WEEKNUM(23746, 21), 1);
2152-assertEquals(WEEKNUM(23747, 21), 1);
2153-assertEquals(WEEKNUM(23748, 21), 1);
2154-assertEquals(WEEKNUM(23749, 21), 1);
2155-assertEquals(WEEKNUM(23750, 21), 1);
2156-assertEquals(WEEKNUM(23751, 21), 1);
2157-assertEquals(WEEKNUM(23752, 21), 1);
2158-assertEquals(WEEKNUM(23753, 21), 2);
2159-assertEquals(WEEKNUM(23754, 21), 2);
2160-assertEquals(WEEKNUM(23755, 21), 2);
2161-assertEquals(WEEKNUM(23756, 21), 2);
2162-assertEquals(WEEKNUM(23757, 21), 2);
2163-assertEquals(WEEKNUM(23758, 21), 2);
2164-assertEquals(WEEKNUM(23759, 21), 2);
2165-assertEquals(WEEKNUM(23760, 21), 3);
2166-// //type=21 again
2167-assertEquals(WEEKNUM(355, 21), 51);
2168-assertEquals(WEEKNUM(356, 21), 51);
2169-assertEquals(WEEKNUM(357, 21), 51);
2170-assertEquals(WEEKNUM(358, 21), 51);
2171-assertEquals(WEEKNUM(359, 21), 52);
2172-assertEquals(WEEKNUM(360, 21), 52);
2173-assertEquals(WEEKNUM(361, 21), 52);
2174-assertEquals(WEEKNUM(362, 21), 52);
2175-assertEquals(WEEKNUM(363, 21), 52);
2176-assertEquals(WEEKNUM(364, 21), 52);
2177-assertEquals(WEEKNUM(365, 21), 52);
2178-assertEquals(WEEKNUM(366, 21), 1);
2179-assertEquals(WEEKNUM(367, 21), 1);
2180-assertEquals(WEEKNUM(368, 21), 1);
2181-assertEquals(WEEKNUM(369, 21), 1);
2182-assertEquals(WEEKNUM(370, 21), 1);
2183-assertEquals(WEEKNUM(371, 21), 1);
2184-assertEquals(WEEKNUM(372, 21), 1);
2185-assertEquals(WEEKNUM(373, 21), 2);
2186-assertEquals(WEEKNUM(374, 21), 2);
2187-assertEquals(WEEKNUM(375, 21), 2);
2188-assertEquals(WEEKNUM(376, 21), 2);
2189-assertEquals(WEEKNUM(377, 21), 2);
2190-assertEquals(WEEKNUM(378, 21), 2);
2191-assertEquals(WEEKNUM(379, 21), 2);
2192-assertEquals(WEEKNUM(380, 21), 3);
2193-assertEquals(WEEKNUM(381, 21), 3);
2194-// //type=21 again
2195-assertEquals(WEEKNUM(728, 21), 52);
2196-assertEquals(WEEKNUM(729, 21), 52);
2197-assertEquals(WEEKNUM(730, 21), 1);
2198-assertEquals(WEEKNUM(731, 21), 1);
2199-assertEquals(WEEKNUM(732, 21), 1);
2200-assertEquals(WEEKNUM(733, 21), 1);
2201-assertEquals(WEEKNUM(734, 21), 1);
2202-assertEquals(WEEKNUM(735, 21), 1);
2203-assertEquals(WEEKNUM(736, 21), 1);
2204-assertEquals(WEEKNUM(737, 21), 2);
2205-assertEquals(WEEKNUM(738, 21), 2);
2206-assertEquals(WEEKNUM(739, 21), 2);
2207-assertEquals(WEEKNUM(740, 21), 2);
2208-assertEquals(WEEKNUM(741, 21), 2);
2209-assertEquals(WEEKNUM(742, 21), 2);
2210-assertEquals(WEEKNUM(743, 21), 2);
2211-assertEquals(WEEKNUM(744, 21), 3);
2212-assertEquals(WEEKNUM(745, 21), 3);
2213-assertEquals(WEEKNUM(746, 21), 3);
2214-catchAndAssertEquals(function() {
2215-  WEEKNUM();
2216-}, ERRORS.NA_ERROR);
2217-catchAndAssertEquals(function() {
2218-  WEEKNUM(213123, 1, 1);
2219-}, ERRORS.NA_ERROR);
2220-catchAndAssertEquals(function() {
2221-  WEEKNUM("str");
2222-}, ERRORS.VALUE_ERROR);
2223-catchAndAssertEquals(function() {
2224-  WEEKNUM([]);
2225-}, ERRORS.REF_ERROR);
2226-catchAndAssertEquals(function() {
2227-  WEEKNUM(-10);
2228-}, ERRORS.NUM_ERROR);
2229-catchAndAssertEquals(function() {
2230-  WEEKNUM(10, 4);
2231-}, ERRORS.NUM_ERROR);
2232-catchAndAssertEquals(function() {
2233-  WEEKNUM(10, 22);
2234-}, ERRORS.NUM_ERROR);
2235 
2236+test("YEAR", function(){
2237+  assertEquals(YEAR(DATE(1992, 6, 24)), 1992);
2238+  assertEquals(YEAR(DATE(2000, 6, 24)), 2000);
2239+  assertEquals(YEAR(DATE(100, 6, 24)), 2000);
2240+  assertEquals(YEAR(DATE(44, 6, 24)), 1944);
2241+  assertEquals(YEAR(1312212), 5492);
2242+  assertEquals(YEAR(9), 1900);
2243+  assertEquals(YEAR(0), 1899);
2244+  assertEquals(YEAR(false), 1899);
2245+  assertEquals(YEAR(1), 1899);
2246+  assertEquals(YEAR(true), 1899);
2247+  assertEquals(YEAR([1, "str"]), 1899);
2248+  catchAndAssertEquals(function() {
2249+    YEAR();
2250+  }, ERRORS.NA_ERROR);
2251+  catchAndAssertEquals(function() {
2252+    YEAR(213123, 123123);
2253+  }, ERRORS.NA_ERROR);
2254+  catchAndAssertEquals(function() {
2255+    YEAR("str");
2256+  }, ERRORS.VALUE_ERROR);
2257+  catchAndAssertEquals(function() {
2258+    YEAR([]);
2259+  }, ERRORS.REF_ERROR);
2260+  catchAndAssertEquals(function() {
2261+    YEAR(-10);
2262+  }, ERRORS.NUM_ERROR);
2263+});
2264 
2265-// Test WEEKDAY
2266-assertEquals(WEEKDAY(DATE(1992, 6, 20)), 7);
2267-assertEquals(WEEKDAY(DATE(1992, 6, 21)), 1);
2268-assertEquals(WEEKDAY(DATE(1992, 6, 24)), 4);
2269-assertEquals(WEEKDAY(DATE(1992, 6, 25)), 5);
2270-assertEquals(WEEKDAY(1312211), 5);
2271-assertEquals(WEEKDAY(1312212), 6);
2272-assertEquals(WEEKDAY(1312213), 7);
2273-assertEquals(WEEKDAY(0), 7);
2274-assertEquals(WEEKDAY(false), 7);
2275-assertEquals(WEEKDAY(1), 1);
2276-assertEquals(WEEKDAY(true), 1);
2277-assertEquals(WEEKDAY(40909, 1), 1);
2278-assertEquals(WEEKDAY(40909, 2), 7);
2279-assertEquals(WEEKDAY(40909, 3), 6);
2280-assertEquals(WEEKDAY(411, 1), 5);
2281-assertEquals(WEEKDAY(411, 2), 4);
2282-assertEquals(WEEKDAY(411, 3), 3);
2283-assertEquals(WEEKDAY(40909, 1), 1);
2284-assertEquals(WEEKDAY(40910, 1), 2);
2285-assertEquals(WEEKDAY(40911, 1), 3);
2286-assertEquals(WEEKDAY(40912, 1), 4);
2287-assertEquals(WEEKDAY(40913, 1), 5);
2288-assertEquals(WEEKDAY(40914, 1), 6);
2289-assertEquals(WEEKDAY(40915, 1), 7);
2290-assertEquals(WEEKDAY(40916, 1), 1);
2291-assertEquals(WEEKDAY(40909, 2), 7);
2292-assertEquals(WEEKDAY(40910, 2), 1);
2293-assertEquals(WEEKDAY(40911, 2), 2);
2294-assertEquals(WEEKDAY(40912, 2), 3);
2295-assertEquals(WEEKDAY(40913, 2), 4);
2296-assertEquals(WEEKDAY(40914, 2), 5);
2297-assertEquals(WEEKDAY(40915, 2), 6);
2298-assertEquals(WEEKDAY(40916, 2), 7);
2299-assertEquals(WEEKDAY(40909, 3), 6);
2300-assertEquals(WEEKDAY(40910, 3), 0);
2301-assertEquals(WEEKDAY(40911, 3), 1);
2302-assertEquals(WEEKDAY(40912, 3), 2);
2303-assertEquals(WEEKDAY(40913, 3), 3);
2304-assertEquals(WEEKDAY(40914, 3), 4);
2305-assertEquals(WEEKDAY(40915, 3), 5);
2306-assertEquals(WEEKDAY(40916, 3), 6);
2307-catchAndAssertEquals(function() {
2308-  WEEKDAY();
2309-}, ERRORS.NA_ERROR);
2310-catchAndAssertEquals(function() {
2311-  WEEKDAY(213123, 1, 1);
2312-}, ERRORS.NA_ERROR);
2313-catchAndAssertEquals(function() {
2314-  WEEKDAY("str");
2315-}, ERRORS.VALUE_ERROR);
2316-catchAndAssertEquals(function() {
2317-  WEEKDAY([]);
2318-}, ERRORS.REF_ERROR);
2319-catchAndAssertEquals(function() {
2320-  WEEKDAY(-10);
2321-}, ERRORS.NUM_ERROR);
2322-catchAndAssertEquals(function() {
2323-  WEEKDAY(10, 4);
2324-}, ERRORS.NUM_ERROR);
2325 
2326+test("MONTH", function(){
2327+  assertEquals(MONTH(DATE(1992, 6, 24)), 6);
2328+  assertEquals(MONTH(1312212), 9);
2329+  assertEquals(MONTH(13122121), 2);
2330+  catchAndAssertEquals(function() {
2331+    MONTH();
2332+  }, ERRORS.NA_ERROR);
2333+  catchAndAssertEquals(function() {
2334+    MONTH(213123, 123123);
2335+  }, ERRORS.NA_ERROR);
2336+  catchAndAssertEquals(function() {
2337+    MONTH("str");
2338+  }, ERRORS.VALUE_ERROR);
2339+  catchAndAssertEquals(function() {
2340+    MONTH([]);
2341+  }, ERRORS.REF_ERROR);
2342+  catchAndAssertEquals(function() {
2343+    MONTH(-10);
2344+  }, ERRORS.NUM_ERROR);
2345+});
2346 
2347-// Test YEAR
2348-assertEquals(YEAR(DATE(1992, 6, 24)), 1992);
2349-assertEquals(YEAR(DATE(2000, 6, 24)), 2000);
2350-assertEquals(YEAR(DATE(100, 6, 24)), 2000);
2351-assertEquals(YEAR(DATE(44, 6, 24)), 1944);
2352-assertEquals(YEAR(1312212), 5492);
2353-assertEquals(YEAR(9), 1900);
2354-assertEquals(YEAR(0), 1899);
2355-assertEquals(YEAR(false), 1899);
2356-assertEquals(YEAR(1), 1899);
2357-assertEquals(YEAR(true), 1899);
2358-assertEquals(YEAR([1, "str"]), 1899);
2359-catchAndAssertEquals(function() {
2360-  YEAR();
2361-}, ERRORS.NA_ERROR);
2362-catchAndAssertEquals(function() {
2363-  YEAR(213123, 123123);
2364-}, ERRORS.NA_ERROR);
2365-catchAndAssertEquals(function() {
2366-  YEAR("str");
2367-}, ERRORS.VALUE_ERROR);
2368-catchAndAssertEquals(function() {
2369-  YEAR([]);
2370-}, ERRORS.REF_ERROR);
2371-catchAndAssertEquals(function() {
2372-  YEAR(-10);
2373-}, ERRORS.NUM_ERROR);
2374 
2375+test("DAYS360", function(){
2376+  assertEquals(DAYS360(DATE(1992, 6, 24), DATE(1992, 6, 25)), 1);
2377+  assertEquals(DAYS360(DATE(1992, 6, 25), DATE(1992, 6, 24)), -1);
2378+  assertEquals(DAYS360(DATE(1992, 6, 25), DATE(1992, 6, 23)), -2);
2379+  assertEquals(DAYS360(DATE(1992, 6, 24), DATE(1991, 6, 24)), -360);
2380+  assertEquals(DAYS360(DATE(1993, 6, 24), DATE(1992, 6, 24)), -360);
2381+  assertEquals(DAYS360(DATEVALUE("1993-6-24"), 1), -33653);
2382+  assertEquals(DAYS360(DATEVALUE("1993-6-24"), true), -33653);
2383+  assertEquals(DAYS360(DATEVALUE("1993-6-24"), 0), -33654);
2384+  assertEquals(DAYS360(DATEVALUE("1993-6-24"), false), -33654);
2385+  assertEquals(DAYS360("2191-6-24", "1992-6-24"), -71640);
2386+  assertEquals(DAYS360("2191-6-24", "1992-6-24", true), -71640);
2387+  assertEquals(DAYS360(1, 390, 1), 384);
2388+  assertEquals(DAYS360(1, 390), 384);
2389+  assertEquals(DAYS360(33779, 33780), 1);
2390+  assertEquals(DAYS360([1, "str"], [390, "str"]), 384);
2391+  catchAndAssertEquals(function() {
2392+    DAYS360();
2393+  }, ERRORS.NA_ERROR);
2394+  catchAndAssertEquals(function() {
2395+    DAYS360(100);
2396+  }, ERRORS.NA_ERROR);
2397+  catchAndAssertEquals(function() {
2398+    DAYS360(100, 200, true, "str");
2399+  }, ERRORS.NA_ERROR);
2400+  catchAndAssertEquals(function() {
2401+    DAYS360("str", 100);
2402+  }, ERRORS.VALUE_ERROR);
2403+  catchAndAssertEquals(function() {
2404+    DAYS360("false", "true");
2405+  }, ERRORS.VALUE_ERROR);
2406+  catchAndAssertEquals(function() {
2407+    DAYS360([[], 100], 22);
2408+  }, ERRORS.REF_ERROR);
2409+});
2410 
2411-// Test MONTH
2412-assertEquals(MONTH(DATE(1992, 6, 24)), 6);
2413-assertEquals(MONTH(1312212), 9);
2414-assertEquals(MONTH(13122121), 2);
2415-catchAndAssertEquals(function() {
2416-  MONTH();
2417-}, ERRORS.NA_ERROR);
2418-catchAndAssertEquals(function() {
2419-  MONTH(213123, 123123);
2420-}, ERRORS.NA_ERROR);
2421-catchAndAssertEquals(function() {
2422-  MONTH("str");
2423-}, ERRORS.VALUE_ERROR);
2424-catchAndAssertEquals(function() {
2425-  MONTH([]);
2426-}, ERRORS.REF_ERROR);
2427-catchAndAssertEquals(function() {
2428-  MONTH(-10);
2429-}, ERRORS.NUM_ERROR);
2430 
2431+test("DAYS", function(){
2432+  assertEquals(DAYS(DATE(1992, 6, 24), DATE(1992, 6, 25)), -1);
2433+  assertEquals(DAYS(DATE(1992, 6, 25), DATE(1992, 6, 24)), 1);
2434+  assertEquals(DAYS(DATE(1992, 6, 25), DATE(1992, 6, 23)), 2);
2435+  assertEquals(DAYS(DATE(1992, 6, 24), DATE(1991, 6, 24)), 366);
2436+  assertEquals(DAYS(DATE(1993, 6, 24), DATE(1992, 6, 24)), 365);
2437+  assertEquals(DAYS("2191-6-24", "1992-6-24"), 72683);
2438+  assertEquals(DAYS(0, 1), -1);
2439+  assertEquals(DAYS(false, true), -1);
2440+  assertEquals(DAYS(0, 100), -100);
2441+  assertEquals(DAYS(-100, 100), -200);
2442+  assertEquals(DAYS(100, -100), 200);
2443+  assertEquals(DAYS(100, 0), 100);
2444+  assertEquals(DAYS([0, "str"], [100, "str"]), -100);
2445+  assertEquals(DAYS("1992, 6, 25", "1992, 6, 24"), 1);
2446+  catchAndAssertEquals(function() {
2447+    DAYS();
2448+  }, ERRORS.NA_ERROR);
2449+  catchAndAssertEquals(function() {
2450+    DAYS(100);
2451+  }, ERRORS.NA_ERROR);
2452+  catchAndAssertEquals(function() {
2453+    DAYS(100, 200, 300);
2454+  }, ERRORS.NA_ERROR);
2455+  catchAndAssertEquals(function() {
2456+    DAYS([[], 100], 22);
2457+  }, ERRORS.REF_ERROR);
2458+  catchAndAssertEquals(function() {
2459+    DAYS("str", 100);
2460+  }, ERRORS.VALUE_ERROR);
2461+  catchAndAssertEquals(function() {
2462+    DAYS("false", "true");
2463+  }, ERRORS.VALUE_ERROR);
2464+});
2465 
2466-// Test DAYS360
2467-assertEquals(DAYS360(DATE(1992, 6, 24), DATE(1992, 6, 25)), 1);
2468-assertEquals(DAYS360(DATE(1992, 6, 25), DATE(1992, 6, 24)), -1);
2469-assertEquals(DAYS360(DATE(1992, 6, 25), DATE(1992, 6, 23)), -2);
2470-assertEquals(DAYS360(DATE(1992, 6, 24), DATE(1991, 6, 24)), -360);
2471-assertEquals(DAYS360(DATE(1993, 6, 24), DATE(1992, 6, 24)), -360);
2472-assertEquals(DAYS360(DATEVALUE("1993-6-24"), 1), -33653);
2473-assertEquals(DAYS360(DATEVALUE("1993-6-24"), true), -33653);
2474-assertEquals(DAYS360(DATEVALUE("1993-6-24"), 0), -33654);
2475-assertEquals(DAYS360(DATEVALUE("1993-6-24"), false), -33654);
2476-assertEquals(DAYS360("2191-6-24", "1992-6-24"), -71640);
2477-assertEquals(DAYS360("2191-6-24", "1992-6-24", true), -71640);
2478-assertEquals(DAYS360(1, 390, 1), 384);
2479-assertEquals(DAYS360(1, 390), 384);
2480-assertEquals(DAYS360(33779, 33780), 1);
2481-assertEquals(DAYS360([1, "str"], [390, "str"]), 384);
2482-catchAndAssertEquals(function() {
2483-  DAYS360();
2484-}, ERRORS.NA_ERROR);
2485-catchAndAssertEquals(function() {
2486-  DAYS360(100);
2487-}, ERRORS.NA_ERROR);
2488-catchAndAssertEquals(function() {
2489-  DAYS360(100, 200, true, "str");
2490-}, ERRORS.NA_ERROR);
2491-catchAndAssertEquals(function() {
2492-  DAYS360("str", 100);
2493-}, ERRORS.VALUE_ERROR);
2494-catchAndAssertEquals(function() {
2495-  DAYS360("false", "true");
2496-}, ERRORS.VALUE_ERROR);
2497-catchAndAssertEquals(function() {
2498-  DAYS360([[], 100], 22);
2499-}, ERRORS.REF_ERROR);
2500 
2501+test("DAY", function(){
2502+  assertEquals(DAY(DATE(1992, 6, 24)), 24);
2503+  assertEquals(DAY(DATE(1992, 5, 10)), 10);
2504+  assertEquals(DAY(DATE(1992, 5, 22)), 22);
2505+  assertEquals(DAY(DATE(1992, 6, 1)), 1);
2506+  assertEquals(DAY(DATE(2008, 1, 31)), 31);
2507+  assertEquals(DAY("1992, 6, 24"), 24);
2508+  assertEquals(DAY(["1992, 6, 24"]), 24);
2509+  assertEquals(DAY(0), 30);
2510+  assertEquals(DAY(false), 30);
2511+  assertEquals(DAY(1), 31);
2512+  assertEquals(DAY(true), 31);
2513+  assertEquals(DAY(33779), 24);
2514+  assertEquals(DAY([33779]), 24);
2515+  assertEquals(DAY([33779, "str"]), 24);
2516+  catchAndAssertEquals(function() {
2517+    DAY("str");
2518+  }, ERRORS.VALUE_ERROR);
2519+  catchAndAssertEquals(function() {
2520+    DAY();
2521+  }, ERRORS.NA_ERROR);
2522+  catchAndAssertEquals(function() {
2523+    DAY(DATE(1992, 6, 24), 4);
2524+  }, ERRORS.NA_ERROR);
2525+  catchAndAssertEquals(function() {
2526+    DAY(-1);
2527+  }, ERRORS.NUM_ERROR);
2528+});
2529 
2530-// Test DAYS
2531-assertEquals(DAYS(DATE(1992, 6, 24), DATE(1992, 6, 25)), -1);
2532-assertEquals(DAYS(DATE(1992, 6, 25), DATE(1992, 6, 24)), 1);
2533-assertEquals(DAYS(DATE(1992, 6, 25), DATE(1992, 6, 23)), 2);
2534-assertEquals(DAYS(DATE(1992, 6, 24), DATE(1991, 6, 24)), 366);
2535-assertEquals(DAYS(DATE(1993, 6, 24), DATE(1992, 6, 24)), 365);
2536-assertEquals(DAYS("2191-6-24", "1992-6-24"), 72683);
2537-assertEquals(DAYS(0, 1), -1);
2538-assertEquals(DAYS(false, true), -1);
2539-assertEquals(DAYS(0, 100), -100);
2540-assertEquals(DAYS(-100, 100), -200);
2541-assertEquals(DAYS(100, -100), 200);
2542-assertEquals(DAYS(100, 0), 100);
2543-assertEquals(DAYS([0, "str"], [100, "str"]), -100);
2544-assertEquals(DAYS("1992, 6, 25", "1992, 6, 24"), 1);
2545-catchAndAssertEquals(function() {
2546-  DAYS();
2547-}, ERRORS.NA_ERROR);
2548-catchAndAssertEquals(function() {
2549-  DAYS(100);
2550-}, ERRORS.NA_ERROR);
2551-catchAndAssertEquals(function() {
2552-  DAYS(100, 200, 300);
2553-}, ERRORS.NA_ERROR);
2554-catchAndAssertEquals(function() {
2555-  DAYS([[], 100], 22);
2556-}, ERRORS.REF_ERROR);
2557-catchAndAssertEquals(function() {
2558-  DAYS("str", 100);
2559-}, ERRORS.VALUE_ERROR);
2560-catchAndAssertEquals(function() {
2561-  DAYS("false", "true");
2562-}, ERRORS.VALUE_ERROR);
2563 
2564+test("EDATE", function(){
2565+  assertEquals(EDATE(DATE(1992, 6, 24), 1), DATE(1992, 7, 24));
2566+  assertEquals(EDATE(DATE(1992, 5, 24), 2), DATE(1992, 7, 24));
2567+  assertEquals(EDATE(DATE(1992, 5, 24), 2.2), DATE(1992, 7, 24));
2568+  assertEquals(EDATE(DATE(1992, 6, 24), 0), DATE(1992, 6, 24));
2569+  assertEquals(EDATE(DATE(1992, 6, 24), false), DATE(1992, 6, 24));
2570+  assertEquals(EDATE("1992, 5, 24", 2), DATE(1992, 7, 24));
2571+  assertEquals(EDATE("6/24/92", 1), DATE(1992, 7, 24));
2572+  assertEquals(EDATE([DATE(1992, 6, 24), "str"], [1, "str"]), DATE(1992, 7, 24));
2573+  assertEquals(EDATE(0, 1), DATE(1900, 1, 30));
2574+  assertEquals(EDATE(false, 1), DATE(1900, 1, 30));
2575+  catchAndAssertEquals(function() {
2576+    EDATE("str", 2);
2577+  }, ERRORS.VALUE_ERROR);
2578+  catchAndAssertEquals(function() {
2579+    EDATE(DATE(1992, 6, 24));
2580+  }, ERRORS.NA_ERROR);
2581+  catchAndAssertEquals(function() {
2582+    EDATE(DATE(1992, 6, 24), 4, 4);
2583+  }, ERRORS.NA_ERROR);
2584+  catchAndAssertEquals(function() {
2585+    EDATE(-1, 1);
2586+  }, ERRORS.NUM_ERROR);
2587+  catchAndAssertEquals(function() {
2588+    EDATE(DATEVALUE("01/13/0101"), 1);
2589+  }, ERRORS.NUM_ERROR);
2590+});
2591 
2592-// Test DAY
2593-assertEquals(DAY(DATE(1992, 6, 24)), 24);
2594-assertEquals(DAY(DATE(1992, 5, 10)), 10);
2595-assertEquals(DAY(DATE(1992, 5, 22)), 22);
2596-assertEquals(DAY(DATE(1992, 6, 1)), 1);
2597-assertEquals(DAY(DATE(2008, 1, 31)), 31);
2598-assertEquals(DAY("1992, 6, 24"), 24);
2599-assertEquals(DAY(["1992, 6, 24"]), 24);
2600-assertEquals(DAY(0), 30);
2601-assertEquals(DAY(false), 30);
2602-assertEquals(DAY(1), 31);
2603-assertEquals(DAY(true), 31);
2604-assertEquals(DAY(33779), 24);
2605-assertEquals(DAY([33779]), 24);
2606-assertEquals(DAY([33779, "str"]), 24);
2607-catchAndAssertEquals(function() {
2608-  DAY("str");
2609-}, ERRORS.VALUE_ERROR);
2610-catchAndAssertEquals(function() {
2611-  DAY();
2612-}, ERRORS.NA_ERROR);
2613-catchAndAssertEquals(function() {
2614-  DAY(DATE(1992, 6, 24), 4);
2615-}, ERRORS.NA_ERROR);
2616-catchAndAssertEquals(function() {
2617-  DAY(-1);
2618-}, ERRORS.NUM_ERROR);
2619 
2620+test("EOMONTH", function(){
2621+  assertEquals(EOMONTH(DATE(1992, 6, 24), 0), DATE(1992, 6, 30));
2622+  assertEquals(EOMONTH(DATE(1992, 6, 24), false), DATE(1992, 6, 30));
2623+  assertEquals(EOMONTH(DATE(1992, 6, 24), 1), DATE(1992, 7, 31));
2624+  assertEquals(EOMONTH(DATE(1992, 6, 24), 2), DATE(1992, 8, 31));
2625+  assertEquals(EOMONTH(DATE(2012, 6, 24), 2), DATE(2012, 8, 31));
2626+  assertEquals(EOMONTH(DATE(2049, 1, 1), 2), DATE(2049, 3, 31));
2627+  assertEquals(EOMONTH(DATE(1990, 2, 24), 400), DATE(2023, 6, 30));
2628+  assertEquals(EOMONTH("1992, 6, 24", 2), DATE(1992, 8, 31));
2629+  //leap years
2630+  assertEquals(EOMONTH(DATE(2004, 2, 24), 0), DATE(2004, 2, 29));
2631+  assertEquals(EOMONTH(DATE(2008, 2, 24), 0), DATE(2008, 2, 29));
2632+  // misc.
2633+  assertEquals(EOMONTH([DATE(1992, 6, 24), "str"], [2, "str"]), DATE(1992, 8, 31));
2634+  assertEquals(EOMONTH(0, 1), DATE(1900, 1, 31));
2635+  assertEquals(EOMONTH(false, 1), DATE(1900, 1, 31));
2636+  assertEquals(EOMONTH(1, 1), DATE(1900, 1, 31));
2637+  assertEquals(EOMONTH(true, 1), DATE(1900, 1, 31));
2638+  catchAndAssertEquals(function() {
2639+    EOMONTH("str", 2);
2640+  }, ERRORS.VALUE_ERROR);
2641+  catchAndAssertEquals(function() {
2642+    EOMONTH(-1, 2);
2643+  }, ERRORS.NUM_ERROR);
2644+});
2645 
2646-// Test EDATE
2647-assertEquals(EDATE(DATE(1992, 6, 24), 1), DATE(1992, 7, 24));
2648-assertEquals(EDATE(DATE(1992, 5, 24), 2), DATE(1992, 7, 24));
2649-assertEquals(EDATE(DATE(1992, 5, 24), 2.2), DATE(1992, 7, 24));
2650-assertEquals(EDATE(DATE(1992, 6, 24), 0), DATE(1992, 6, 24));
2651-assertEquals(EDATE(DATE(1992, 6, 24), false), DATE(1992, 6, 24));
2652-assertEquals(EDATE("1992, 5, 24", 2), DATE(1992, 7, 24));
2653-assertEquals(EDATE("6/24/92", 1), DATE(1992, 7, 24));
2654-assertEquals(EDATE([DATE(1992, 6, 24), "str"], [1, "str"]), DATE(1992, 7, 24));
2655-assertEquals(EDATE(0, 1), DATE(1900, 1, 30));
2656-assertEquals(EDATE(false, 1), DATE(1900, 1, 30));
2657-catchAndAssertEquals(function() {
2658-  EDATE("str", 2);
2659-}, ERRORS.VALUE_ERROR);
2660-catchAndAssertEquals(function() {
2661-  EDATE(DATE(1992, 6, 24));
2662-}, ERRORS.NA_ERROR);
2663-catchAndAssertEquals(function() {
2664-  EDATE(DATE(1992, 6, 24), 4, 4);
2665-}, ERRORS.NA_ERROR);
2666-catchAndAssertEquals(function() {
2667-  EDATE(-1, 1);
2668-}, ERRORS.NUM_ERROR);
2669-catchAndAssertEquals(function() {
2670-  EDATE(DATEVALUE("01/13/0101"), 1);
2671-}, ERRORS.NUM_ERROR);
2672 
2673+test("DATE", function(){
2674+  assertEquals(DATE(1900, 1, 2).toNumber(), 3);
2675+  assertEquals(DATE(1900, 1, 1).toNumber(), 2);
2676+  assertEquals(DATE(1900, 1, 4).toNumber(), 5);
2677+  catchAndAssertEquals(function() {
2678+    DATE(1900, 0, 5);
2679+  }, ERRORS.NUM_ERROR);
2680+  catchAndAssertEquals(function() {
2681+    DATE(1900, 0, 5, 22);
2682+  }, ERRORS.NA_ERROR);
2683+  catchAndAssertEquals(function() {
2684+    DATE(1900, 0);
2685+  }, ERRORS.NA_ERROR);
2686+  assertEquals(DATE(1992, 6, 24).toNumber(), 33779);
2687+  assertEquals(DATE(2017, 2, 26).toNumber(), 42792);
2688+  assertEquals(DATE(1999, 1, 13).toNumber(), 36173);
2689+  // Leap day stuff
2690+  assertEquals(DATE(2004, 2, 28).toNumber(), 38045);
2691+  assertEquals(DATE(2004, 2, 29).toNumber(), 38046);
2692+  assertEquals(DATE(2004, 3, 1).toNumber(), 38047);
2693+  // Overflow values
2694+  assertEquals(DATE(1992, 6, 44).toNumber(), 33799);
2695+  assertEquals(DATE(2, 33, 44).toNumber(), 1749);
2696+  assertEquals(DATE(1777, 33, 44).toNumber(), 650055);
2697+  assertEquals(DATE(1976, 2, -10).toNumber(), 27780);
2698+  assertEquals(DATE(-1900, 1, 1).toNumber(), 2);
2699+  assertEquals(DATE(1992, 1, 10).toNumber(), 33613);
2700+});
2701 
2702-// Test EOMONTH
2703-assertEquals(EOMONTH(DATE(1992, 6, 24), 0), DATE(1992, 6, 30));
2704-assertEquals(EOMONTH(DATE(1992, 6, 24), false), DATE(1992, 6, 30));
2705-assertEquals(EOMONTH(DATE(1992, 6, 24), 1), DATE(1992, 7, 31));
2706-assertEquals(EOMONTH(DATE(1992, 6, 24), 2), DATE(1992, 8, 31));
2707-assertEquals(EOMONTH(DATE(2012, 6, 24), 2), DATE(2012, 8, 31));
2708-assertEquals(EOMONTH(DATE(2049, 1, 1), 2), DATE(2049, 3, 31));
2709-assertEquals(EOMONTH(DATE(1990, 2, 24), 400), DATE(2023, 6, 30));
2710-assertEquals(EOMONTH("1992, 6, 24", 2), DATE(1992, 8, 31));
2711-//leap years
2712-assertEquals(EOMONTH(DATE(2004, 2, 24), 0), DATE(2004, 2, 29));
2713-assertEquals(EOMONTH(DATE(2008, 2, 24), 0), DATE(2008, 2, 29));
2714-// misc.
2715-assertEquals(EOMONTH([DATE(1992, 6, 24), "str"], [2, "str"]), DATE(1992, 8, 31));
2716-assertEquals(EOMONTH(0, 1), DATE(1900, 1, 31));
2717-assertEquals(EOMONTH(false, 1), DATE(1900, 1, 31));
2718-assertEquals(EOMONTH(1, 1), DATE(1900, 1, 31));
2719-assertEquals(EOMONTH(true, 1), DATE(1900, 1, 31));
2720-catchAndAssertEquals(function() {
2721-  EOMONTH("str", 2);
2722-}, ERRORS.VALUE_ERROR);
2723-catchAndAssertEquals(function() {
2724-  EOMONTH(-1, 2);
2725-}, ERRORS.NUM_ERROR);
2726 
2727-
2728-// Test DATE
2729-assertEquals(DATE(1900, 1, 2).toNumber(), 3);
2730-assertEquals(DATE(1900, 1, 1).toNumber(), 2);
2731-assertEquals(DATE(1900, 1, 4).toNumber(), 5);
2732-catchAndAssertEquals(function() {
2733-  DATE(1900, 0, 5);
2734-}, ERRORS.NUM_ERROR);
2735-catchAndAssertEquals(function() {
2736-  DATE(1900, 0, 5, 22);
2737-}, ERRORS.NA_ERROR);
2738-catchAndAssertEquals(function() {
2739-  DATE(1900, 0);
2740-}, ERRORS.NA_ERROR);
2741-assertEquals(DATE(1992, 6, 24).toNumber(), 33779);
2742-assertEquals(DATE(2017, 2, 26).toNumber(), 42792);
2743-assertEquals(DATE(1999, 1, 13).toNumber(), 36173);
2744-// Leap day stuff
2745-assertEquals(DATE(2004, 2, 28).toNumber(), 38045);
2746-assertEquals(DATE(2004, 2, 29).toNumber(), 38046);
2747-assertEquals(DATE(2004, 3, 1).toNumber(), 38047);
2748-// Overflow values
2749-assertEquals(DATE(1992, 6, 44).toNumber(), 33799);
2750-assertEquals(DATE(2, 33, 44).toNumber(), 1749);
2751-assertEquals(DATE(1777, 33, 44).toNumber(), 650055);
2752-assertEquals(DATE(1976, 2, -10).toNumber(), 27780);
2753-assertEquals(DATE(-1900, 1, 1).toNumber(), 2);
2754-assertEquals(DATE(1992, 1, 10).toNumber(), 33613);
2755-
2756-
2757-
2758-// Test DATEVALUE
2759-assertEquals(DATEVALUE("6/24/92"), 33779);
2760-assertEquals(DATEVALUE(["6/24/92", false]), 33779);
2761-catchAndAssertEquals(function() {
2762-  DATEVALUE("6/24/92", 10);
2763-}, ERRORS.NA_ERROR);
2764-catchAndAssertEquals(function() {
2765-  DATEVALUE();
2766-}, ERRORS.NA_ERROR);
2767-catchAndAssertEquals(function() {
2768-  DATEVALUE(false);
2769-}, ERRORS.VALUE_ERROR);
2770-// MONTHDIG_DAY_YEAR, MM(fd)DD(fd)YYYY =================================================================================
2771-assertEquals(DATEVALUE("6/24/92"), 33779);
2772-assertEquals(DATEVALUE("6/24/1992"), 33779);
2773-assertEquals(DATEVALUE("06/24/1992"), 33779);
2774-assertEquals(DATEVALUE("1/01/1999"), 36161);
2775-assertEquals(DATEVALUE("1/01/99"), 36161);
2776-assertEquals(DATEVALUE("1/01/2222"), 117610);
2777-assertEquals(DATEVALUE("9/02/1902"), 976);
2778-assertEquals(DATEVALUE("9/2/1902"), 976);
2779-assertEquals(DATEVALUE("11/3/4243"), 856071);
2780-assertEquals(DATEVALUE("  04/19/1992  "), 33713);
2781-assertEquals(DATEVALUE("5/20/1992"), 33744);
2782-assertEquals(DATEVALUE("6/21/1992"), 33776);
2783-assertEquals(DATEVALUE("9/29/1992"), 33876);
2784-assertEquals(DATEVALUE("1/24/1992"), 33627);
2785-assertEquals(DATEVALUE("12/21/1992"), 33959);
2786-assertEquals(DATEVALUE("01/31/1992"), 33634);
2787-assertEquals(DATEVALUE("1/13/1992"), 33616);
2788-assertEquals(DATEVALUE("2/29/2004"), 38046);
2789-assertEquals(DATEVALUE("2/28/2004"), 38045);
2790-assertEquals(DATEVALUE("2/28/004"), 38045);
2791-assertEquals(DATEVALUE("2/28/04"), 38045);
2792-assertEquals(DATEVALUE("2/28/4"), 38045);
2793-assertEquals(DATEVALUE("1/13/1999"), 36173);
2794-assertEquals(DATEVALUE("01/13/1999"), 36173);
2795-assertEquals(DATEVALUE("01/13/0999"), -329069);
2796-assertEquals(DATEVALUE("01/13/1200"), -255656);
2797-assertEquals(DATEVALUE("01/13/0029"), 47131);
2798-assertEquals(DATEVALUE("01/13/0030"), 10971);
2799-assertEquals(DATEVALUE("01/13/0044"), 16084);
2800-assertEquals(DATEVALUE("01/13/0050"), 18276);
2801-assertEquals(DATEVALUE("01/13/0097"), 35443);
2802-assertEquals(DATEVALUE("01/13/0099"), 36173);
2803-assertEquals(DATEVALUE("01/13/0000"), 36538);
2804-assertEquals(DATEVALUE("01/13/0101"), -657057);
2805-assertEquals(DATEVALUE("01/13/0100"), -657422);
2806-assertEquals(DATEVALUE("12/31/100"), -657070);
2807-assertEquals(DATEVALUE("11/10/122"), -649086);
2808-assertEquals(DATEVALUE("1/22/2222"), 117631);
2809-assertEquals(DATEVALUE("1/22/222"), -612854);
2810-// delimiter tests
2811-assertEquals(DATEVALUE("6-24-92"), 33779);
2812-assertEquals(DATEVALUE("6/24/92"), 33779);
2813-assertEquals(DATEVALUE("6 24 92"), 33779);
2814-assertEquals(DATEVALUE("6.24.92"), 33779);
2815-assertEquals(DATEVALUE("6 . 24 . 92"), 33779);
2816-assertEquals(DATEVALUE("6 / 24 / 92"), 33779);
2817-assertEquals(DATEVALUE("6, 24, 92"), 33779);
2818-// flex delimiter should not allow a comma without a space after it.
2819-catchAndAssertEquals(function() {
2820-  DATEVALUE("Sunday,6/24/92");
2821-}, ERRORS.VALUE_ERROR);
2822-// Leap day on non-leap years
2823-catchAndAssertEquals(function() {
2824-  DATEVALUE("2/29/2005");
2825-}, ERRORS.VALUE_ERROR);
2826-catchAndAssertEquals(function() {
2827-  DATEVALUE("2/29/2001");
2828-}, ERRORS.VALUE_ERROR);
2829-// Out of range day for any month
2830-catchAndAssertEquals(function() {
2831-  DATEVALUE("1/44/2005");
2832-}, ERRORS.VALUE_ERROR);
2833-// timestamp test
2834-assertEquals(DATEVALUE("6-24-92 10am"), 33779);
2835-assertEquals(DATEVALUE("6-24-92 10:10"), 33779);
2836-assertEquals(DATEVALUE("6-24-92 10:10am"), 33779);
2837-assertEquals(DATEVALUE("6-24-92 10:10:10"), 33779);
2838-assertEquals(DATEVALUE("6-24-92 10:10:10am"), 33779);
2839-assertEquals(DATEVALUE("6-24-92  10  am"), 33779);
2840-assertEquals(DATEVALUE("6-24-92 10: 10 "), 33779);
2841-assertEquals(DATEVALUE("6-24-92 10: 10 pm"), 33779);
2842-assertEquals(DATEVALUE("6-24-92 10: 10: 10"), 33779);
2843-assertEquals(DATEVALUE("6-24-92  10: 10: 10    am  "), 33779);
2844-assertEquals(DATEVALUE("1992/6/24 00:00"), 33779);
2845-assertEquals(DATEVALUE("1992/6/24 0:00"), 33779);
2846-assertEquals(DATEVALUE("1992/6/24 10:10"), 33779);
2847-assertEquals(DATEVALUE("1992/6/24 16:22"), 33779);
2848-assertEquals(DATEVALUE("1992/6/24 25:10"), 33780);
2849-assertEquals(DATEVALUE("1992/6/24 23:60"), 33780);
2850-assertEquals(DATEVALUE("1992/6/24 24:00"), 33780);
2851-assertEquals(DATEVALUE("1992/6/24 23:59"), 33779);
2852-assertEquals(DATEVALUE("1999/1/13 10:11111111"), 43889);
2853-assertEquals(DATEVALUE("1999/1/13 25000:22"), 37214);
2854-assertEquals(DATEVALUE("1999/1/13 25000:    22"), 37214);
2855-assertEquals(DATEVALUE("1992/6/24 00:00am"), 33779);
2856-assertEquals(DATEVALUE("1992/06/24 01:44am "), 33779);
2857-assertEquals(DATEVALUE("1999/1/01 02:59pm"), 36161);
2858-assertEquals(DATEVALUE("2222/1/01 03:33pm"), 117610);
2859-assertEquals(DATEVALUE("1902/9/02 12:33pm"), 976);
2860-assertEquals(DATEVALUE("1902/9/2 12:33pm"), 976);
2861-assertEquals(DATEVALUE("4243/11/3 12:33pm"), 856071);
2862-assertEquals(DATEVALUE("  1992/04/19   12:  33pm   "), 33713);
2863-assertEquals(DATEVALUE("1992/5/20 01:33am"), 33744);
2864-assertEquals(DATEVALUE("1992/6/21  3:33pm"), 33776);
2865-assertEquals(DATEVALUE("1992/9/29 3:33pm"), 33876);
2866-assertEquals(DATEVALUE("1992/1/24 3:33pm"), 33627);
2867-assertEquals(DATEVALUE("1992/12/21 3:33pm"), 33959);
2868-assertEquals(DATEVALUE("1992/01/31 3:33pm"), 33634);
2869-assertEquals(DATEVALUE("1992/1/13 3:33pm"), 33616);
2870-assertEquals(DATEVALUE("2004/2/29 3:33pm"), 38046);
2871-assertEquals(DATEVALUE("2004/2/28  3:33pm "), 38045);
2872-assertEquals(DATEVALUE("1999/1/13 3:33pm"), 36173);
2873-assertEquals(DATEVALUE("1999/01/13 3:33pm"), 36173);
2874-assertEquals(DATEVALUE("0999/01/13 3:33pm"), -329069);
2875-assertEquals(DATEVALUE("1200/01/13 3:33pm"), -255656);
2876-assertEquals(DATEVALUE("0029/01/13 3:33pm"), 47131);
2877-assertEquals(DATEVALUE("0030/01/13 3:33pm"), 10971);
2878-assertEquals(DATEVALUE("0044/01/13 3:33pm"), 16084);
2879-assertEquals(DATEVALUE("0050/01/13 3:33pm"), 18276);
2880-assertEquals(DATEVALUE("0097/01/13 00:33pm"), 35443);
2881-assertEquals(DATEVALUE("0099/01/13 3:33pm"), 36173);
2882-assertEquals(DATEVALUE("0000/01/13 3:33pm"), 36538);
2883-assertEquals(DATEVALUE("0101/01/13 3:33pm"), -657057);
2884-assertEquals(DATEVALUE("0100/01/13 3:33pm"), -657422);
2885-assertEquals(DATEVALUE("100/12/31 3:33pm"), -657070);
2886-assertEquals(DATEVALUE("122/11/10 3:33pm"), -649086);
2887-assertEquals(DATEVALUE("2222/1/22 3:33pm"), 117631);
2888-assertEquals(DATEVALUE("222/1/22 3:33pm"), -612854);
2889-assertEquals(DATEVALUE("1992/1/13 6:22222222am"), 49048); // overload minutes
2890-assertEquals(DATEVALUE("1992/1/13 12:720pm"), 33617); // overload minutes
2891-assertEquals(DATEVALUE("1992/1/13 00:720pm"), 33617); // overload minutes
2892-assertEquals(DATEVALUE("1992/1/13 12:719pm"), 33616); // overload minutes
2893-assertEquals(DATEVALUE("1992/1/13 00:720am"), 33616); // overload minutes
2894-assertEquals(DATEVALUE("1992/1/13 00:01pm"), 33616); // overload minutes
2895-assertEquals(DATEVALUE("1992/1/13 12:66669pm"), 33662); // overload minutes
2896-assertEquals(DATEVALUE("1992/1/13 12:66669am"), 33662); // overload minutes
2897-assertEquals(DATEVALUE("1992/1/13 12:66249pm"), 33662); // overload minutes
2898-assertEquals(DATEVALUE("1992/1/13 12:66249am"), 33662); // overload minutes
2899-assertEquals(DATEVALUE("1992/1/13 12:666669am"), 34078); // overload minutes
2900-assertEquals(DATEVALUE("1992/1/13 12:666669pm"), 34079); // overload minutes
2901-assertEquals(DATEVALUE("1992/1/13 12:100000000am"), 103060); // overload minutes
2902-assertEquals(DATEVALUE("1992/1/13 12:0912347287am"), 667190); // overload minutes
2903-assertEquals(DATEVALUE("1992/1/13 12:00000912347287am"), 667190); // overload minutes
2904-assertEquals(DATEVALUE("1992/1/13 12:1989198298am"), 1415003); // overload minutes
2905-assertEquals(DATEVALUE("1992/6/24 0:0:0"), 33779);
2906-assertEquals(DATEVALUE("1992/6/24 0000:0000:0000"), 33779);
2907-assertEquals(DATEVALUE("0000/01/13 3:33:999999999"), 48112); // overload seconds
2908-assertEquals(DATEVALUE("1992/1/13 6:22222222:0"), 49048); // overload minutes
2909-assertEquals(DATEVALUE("1992/1/13 12:912347287:10"), 667191); // overload minutes
2910-assertEquals(DATEVALUE("1992/1/13 12:100000000:10"), 103060); // overload minutes
2911-assertEquals(DATEVALUE("1992/1/13 23:720:10"), 33617); // overload minutes
2912-assertEquals(DATEVALUE("1992/1/13 23:719:60"), 33617); // overload minutes, seconds
2913-assertEquals(DATEVALUE("1992/6/24 24:00:00"), 33780); // overload hours
2914-assertEquals(DATEVALUE("1999/1/01 200000000:999999999:923231312"), 9074624); // overload hours, minutes, seconds
2915-assertEquals(DATEVALUE("  1992/04/19   12:  33: 11  "), 33713);
2916-assertEquals(DATEVALUE("0000/01/13 3:33:33"), 36538);
2917-assertEquals(DATEVALUE("4243/11/3 200000000:33:444"), 9189404);
2918-assertEquals(DATEVALUE("1999/1/13 10:10:10pm"), 36173);
2919-assertEquals(DATEVALUE("1992/6/24 0:0:0pm"), 33779);
2920-assertEquals(DATEVALUE("1992/6/24 00:0000:0000pm"), 33779);
2921-assertEquals(DATEVALUE("0000/01/13 3:33:999999999pm"), 48112); // overload seconds
2922-assertEquals(DATEVALUE("1992/1/13 6:22222222:0pm"), 49048); // overload minutes
2923-assertEquals(DATEVALUE("1992/1/13 12:912347287:10pm"), 667191); // overload minutes
2924-assertEquals(DATEVALUE("1992/1/13 12:100000000:10pm"), 103060); // overload minutes
2925-assertEquals(DATEVALUE("1992/6/24 00:00:00am"), 33779);
2926-assertEquals(DATEVALUE("1992/06/24 01:44:00am "), 33779);
2927-assertEquals(DATEVALUE("1999/1/01 02:59:00pm"), 36161);
2928-assertEquals(DATEVALUE("2222/1/01 03:33:00pm"), 117610);
2929-assertEquals(DATEVALUE("1902/9/02 12:33:00pm"), 976);
2930-assertEquals(DATEVALUE("1902/9/2 12:33:00pm"), 976);
2931-assertEquals(DATEVALUE("4243/11/3 12:33:00pm"), 856071);
2932-assertEquals(DATEVALUE("  1992/04/19   12:  33:  00  pm   "), 33713);
2933-assertEquals(DATEVALUE("1992/5/20 01:33:44am"), 33744);
2934-assertEquals(DATEVALUE("1992/6/21  3:33:44pm"), 33776);
2935-assertEquals(DATEVALUE("1992/9/29 3:33:44pm"), 33876);
2936-assertEquals(DATEVALUE("1992/1/24 3:33:44pm"), 33627);
2937-assertEquals(DATEVALUE("1992/12/21 3:33:44pm"), 33959);
2938-assertEquals(DATEVALUE("1992/01/31 3:33:44pm"), 33634);
2939-assertEquals(DATEVALUE("1992/1/13 3:33:44pm"), 33616);
2940-assertEquals(DATEVALUE("2004/2/29 3:33:44pm"), 38046);
2941-assertEquals(DATEVALUE("2004/2/28  3:33:44pm "), 38045);
2942-assertEquals(DATEVALUE("1999/1/13 3:33:44pm"), 36173);
2943-assertEquals(DATEVALUE("1999/01/13 3:33:44pm"), 36173);
2944-assertEquals(DATEVALUE("0999/01/13 3:33:44pm"), -329069);
2945-assertEquals(DATEVALUE("1200/01/13 3:33:44pm"), -255656);
2946-assertEquals(DATEVALUE("0029/01/13 3:33:44pm"), 47131);
2947-assertEquals(DATEVALUE("0030/01/13 3:33:44pm"), 10971);
2948-assertEquals(DATEVALUE("0044/01/13 3:33:44pm"), 16084);
2949-assertEquals(DATEVALUE("0050/01/13 3:33:44pm"), 18276);
2950-assertEquals(DATEVALUE("0097/01/13 00:33:44pm"), 35443);
2951-assertEquals(DATEVALUE("0099/01/13 3:33:44pm"), 36173);
2952-assertEquals(DATEVALUE("0000/01/13 3:33:44pm"), 36538);
2953-assertEquals(DATEVALUE("0101/01/13 3:33:44pm"), -657057);
2954-assertEquals(DATEVALUE("0100/01/13 3:33:44pm"), -657422);
2955-assertEquals(DATEVALUE("100/12/31 3:33:44pm"), -657070);
2956-assertEquals(DATEVALUE("122/11/10 3:33:44pm"), -649086);
2957-assertEquals(DATEVALUE("2222/1/22 3:33:44pm"), 117631);
2958-assertEquals(DATEVALUE("222/1/22 3:33:44pm"), -612854);
2959-assertEquals(DATEVALUE("1992/1/13 6:22222222:44am"), 49048); // overload minutes
2960-assertEquals(DATEVALUE("1992/1/13 12:720:00pm"), 33617); // overload minutes
2961-assertEquals(DATEVALUE("1992/1/13 00:720:00pm"), 33617); // overload minutes
2962-assertEquals(DATEVALUE("1992/1/13 12:719:00pm"), 33616); // overload minutes
2963-assertEquals(DATEVALUE("1992/1/13 00:720:00am"), 33616); // overload minutes
2964-assertEquals(DATEVALUE("1992/1/13 12:719:60pm"), 33617); // overload minutes
2965-assertEquals(DATEVALUE("1992/1/13 00:720:00am"), 33616); // overload minutes
2966-assertEquals(DATEVALUE("1992/1/13 00:01:00pm"), 33616); // overload minutes
2967-assertEquals(DATEVALUE("1992/1/13 12:66669:00pm"), 33662); // overload minutes
2968-assertEquals(DATEVALUE("1992/1/13 12:66669:00am"), 33662); // overload minutes
2969-assertEquals(DATEVALUE("1992/1/13 12:66249:00pm"), 33662); // overload minutes
2970-assertEquals(DATEVALUE("1992/1/13 12:66249:00am"), 33662); // overload minutes
2971-assertEquals(DATEVALUE("1992/1/13 12:666669:00am"), 34078); // overload minutes
2972-assertEquals(DATEVALUE("1992/1/13 12:666669:00pm"), 34079); // overload minutes
2973-assertEquals(DATEVALUE("1992/1/13 12:100000000:00am"), 103060); // overload minutes
2974-assertEquals(DATEVALUE("1992/1/13 12:912347287:00am"), 667190); // overload minutes
2975-// YEAR_MONTHDIG_DAY, YYYY(fd)MM(fd)DD =================================================================================
2976-assertEquals(DATEVALUE("1992/6/24"), 33779);
2977-assertEquals(DATEVALUE("1992/06/24"), 33779);
2978-assertEquals(DATEVALUE("1999/1/01"), 36161);
2979-assertEquals(DATEVALUE("2222/1/01"), 117610);
2980-assertEquals(DATEVALUE("1902/9/02"), 976);
2981-assertEquals(DATEVALUE("1902/9/2"), 976);
2982-assertEquals(DATEVALUE("4243/11/3"), 856071);
2983-assertEquals(DATEVALUE("  1992/04/19  "), 33713);
2984-assertEquals(DATEVALUE("  1992 /  04/ 19  "), 33713);
2985-assertEquals(DATEVALUE("1992/5/20"), 33744);
2986-assertEquals(DATEVALUE("1992/6/21"), 33776);
2987-assertEquals(DATEVALUE("1992/9/29"), 33876);
2988-assertEquals(DATEVALUE("1992/1/24"), 33627);
2989-assertEquals(DATEVALUE("1992/12/21"), 33959);
2990-assertEquals(DATEVALUE("1992/01/31"), 33634);
2991-assertEquals(DATEVALUE("1992/1/13"), 33616);
2992-assertEquals(DATEVALUE("2004/2/29"), 38046);
2993-assertEquals(DATEVALUE("2004/2/28"), 38045);
2994-assertEquals(DATEVALUE("1999/1/13"), 36173);
2995-assertEquals(DATEVALUE("1999/01/13"), 36173);
2996-assertEquals(DATEVALUE("0999/01/13"), -329069);
2997-assertEquals(DATEVALUE("1200/01/13"), -255656);
2998-assertEquals(DATEVALUE("0029/01/13"), 47131);
2999-assertEquals(DATEVALUE("0030/01/13"), 10971);
3000-assertEquals(DATEVALUE("0044/01/13"), 16084);
3001-assertEquals(DATEVALUE("0050/01/13"), 18276);
3002-assertEquals(DATEVALUE("0097/01/13"), 35443);
3003-assertEquals(DATEVALUE("0099/01/13"), 36173);
3004-assertEquals(DATEVALUE("0000/01/13"), 36538);
3005-assertEquals(DATEVALUE("0101/01/13"), -657057);
3006-assertEquals(DATEVALUE("0100/01/13"), -657422);
3007-assertEquals(DATEVALUE("100/12/31"), -657070);
3008-assertEquals(DATEVALUE("122/11/10"), -649086);
3009-assertEquals(DATEVALUE("2222/1/22"), 117631);
3010-assertEquals(DATEVALUE("222/1/22"), -612854);
3011-assertEquals(DATEVALUE("Sunday 1992/6/24"), 33779);
3012-assertEquals(DATEVALUE("Monday 1992/6/24"), 33779);
3013-assertEquals(DATEVALUE("Tuesday 1992/6/24"), 33779);
3014-assertEquals(DATEVALUE("Wednesday 1992/6/24"), 33779);
3015-assertEquals(DATEVALUE("Thursday 1992/6/24"), 33779);
3016-assertEquals(DATEVALUE("Friday 1992/6/24"), 33779);
3017-assertEquals(DATEVALUE("Saturday 1992/6/24"), 33779);
3018-assertEquals(DATEVALUE("Sun 1992/6/24"), 33779);
3019-assertEquals(DATEVALUE("Mon 1992/6/24"), 33779);
3020-assertEquals(DATEVALUE("Tue 1992/6/24"), 33779);
3021-assertEquals(DATEVALUE("Wed 1992/6/24"), 33779);
3022-assertEquals(DATEVALUE("Thu 1992/6/24"), 33779);
3023-assertEquals(DATEVALUE("Fri 1992/6/24"), 33779);
3024-assertEquals(DATEVALUE("Sat 1992/6/24"), 33779);
3025-assertEquals(DATEVALUE("Sunday, 1992/6/24"), 33779);
3026-// delimiter tests
3027-assertEquals(DATEVALUE("1992-6-24"), 33779);
3028-assertEquals(DATEVALUE("1992/6/24"), 33779);
3029-assertEquals(DATEVALUE("1992 6 24"), 33779);
3030-assertEquals(DATEVALUE("1992 6 24"), 33779);
3031-assertEquals(DATEVALUE("1992 . 6 . 24"), 33779);
3032-assertEquals(DATEVALUE("1992 / 6 / 24"), 33779);
3033-assertEquals(DATEVALUE("1992, 6, 24"), 33779);
3034-// flex delimiter should not allow a comma without a space after it.
3035-catchAndAssertEquals(function() {
3036-  DATEVALUE("Sunday,1992/6/24");
3037-}, ERRORS.VALUE_ERROR);
3038-// Leap day on non-leap years
3039-catchAndAssertEquals(function() {
3040-  DATEVALUE("2005/2/29");
3041-}, ERRORS.VALUE_ERROR);
3042-catchAndAssertEquals(function() {
3043-  DATEVALUE("2001/2/29");
3044-}, ERRORS.VALUE_ERROR);
3045-// Out of range day for any month
3046-catchAndAssertEquals(function() {
3047-  DATEVALUE("2005/1/44");
3048-}, ERRORS.VALUE_ERROR);
3049-// timestamp test
3050-assertEquals(DATEVALUE("1992-6-24 10am"), 33779);
3051-assertEquals(DATEVALUE("1992-6-24 10:10"), 33779);
3052-assertEquals(DATEVALUE("1992-6-24 10:10am"), 33779);
3053-assertEquals(DATEVALUE("1992-6-24 10:10:10"), 33779);
3054-assertEquals(DATEVALUE("1992-6-24 10:10:10am"), 33779);
3055-assertEquals(DATEVALUE("1992-6-24  10  am"), 33779);
3056-assertEquals(DATEVALUE("1992-6-24 10: 10 "), 33779);
3057-assertEquals(DATEVALUE("1992-6-24 10: 10 pm"), 33779);
3058-assertEquals(DATEVALUE("1992-6-24 10: 10: 10"), 33779);
3059-assertEquals(DATEVALUE("1992-6-24  10: 10: 10    am   "), 33779);
3060-assertEquals(DATEVALUE("1992/6/24 00am"), 33779);
3061-assertEquals(DATEVALUE("1992/06/24 01am "), 33779);
3062-assertEquals(DATEVALUE("1999/1/01 02pm"), 36161);
3063-assertEquals(DATEVALUE("2222/1/01 03pm"), 117610);
3064-assertEquals(DATEVALUE("1902/9/02 12pm"), 976);
3065-assertEquals(DATEVALUE("1902/9/2 12pm"), 976);
3066-assertEquals(DATEVALUE("4243/11/3 12pm   "), 856071);
3067-assertEquals(DATEVALUE("  1992/04/19   12pm   "), 33713);
3068-assertEquals(DATEVALUE("1992/5/20 01am"), 33744);
3069-assertEquals(DATEVALUE("1992/6/21  3pm"), 33776);
3070-assertEquals(DATEVALUE("1992/9/29 3pm"), 33876);
3071-assertEquals(DATEVALUE("1992/1/24 3pm"), 33627);
3072-assertEquals(DATEVALUE("1992/12/21 3pm"), 33959);
3073-assertEquals(DATEVALUE("1992/01/31 3pm"), 33634);
3074-assertEquals(DATEVALUE("1992/1/13 3pm"), 33616);
3075-assertEquals(DATEVALUE("2004/2/29 3pm"), 38046);
3076-assertEquals(DATEVALUE("2004/2/28  3pm "), 38045);
3077-assertEquals(DATEVALUE("1999/1/13 3pm"), 36173);
3078-assertEquals(DATEVALUE("1999/01/13 3pm"), 36173);
3079-assertEquals(DATEVALUE("0999/01/13 3pm"), -329069);
3080-assertEquals(DATEVALUE("1200/01/13 3pm"), -255656);
3081-assertEquals(DATEVALUE("0029/01/13 3pm"), 47131);
3082-assertEquals(DATEVALUE("0030/01/13 3pm"), 10971);
3083-assertEquals(DATEVALUE("0044/01/13 3pm"), 16084);
3084-assertEquals(DATEVALUE("0050/01/13 3pm"), 18276);
3085-assertEquals(DATEVALUE("0097/01/13 00pm"), 35443);
3086-assertEquals(DATEVALUE("0099/01/13 3pm"), 36173);
3087-assertEquals(DATEVALUE("0000/01/13 3pm"), 36538);
3088-assertEquals(DATEVALUE("0101/01/13 3pm"), -657057);
3089-assertEquals(DATEVALUE("0100/01/13 3pm"), -657422);
3090-assertEquals(DATEVALUE("100/12/31 3pm"), -657070);
3091-assertEquals(DATEVALUE("122/11/10 3pm"), -649086);
3092-assertEquals(DATEVALUE("2222/1/22 3pm"), 117631);
3093-assertEquals(DATEVALUE("222/1/22 3pm"), -612854);
3094-catchAndAssertEquals(function() {
3095-  DATEVALUE("2005/2/29 000pm");// Too many digits
3096-}, ERRORS.VALUE_ERROR);
3097-catchAndAssertEquals(function() {
3098-  DATEVALUE("2001/2/2 13pm");// Hour out of range
3099-}, ERRORS.VALUE_ERROR);
3100-// DAY_MONTHNAME_YEAR, DD(fd)Month(fd)YYYY =============================================================================
3101-assertEquals(DATEVALUE("Sun 09 Feb 2017"), 42775);
3102-assertEquals(DATEVALUE("Sun 9 Feb 2017"), 42775);
3103-assertEquals(DATEVALUE("Mon 09 Feb 2017"), 42775);
3104-assertEquals(DATEVALUE("Thursday 09 Feb 2017"), 42775);
3105-assertEquals(DATEVALUE("Thursday 09 February 2017"), 42775);
3106-assertEquals(DATEVALUE("Sun 01 September 20"), 44075);
3107-assertEquals(DATEVALUE("Sun, 09, Feb, 2017"), 42775);
3108-assertEquals(DATEVALUE("20 May 1992"), 33744);
3109-assertEquals(DATEVALUE("31 December 100"), -657070);
3110-assertEquals(DATEVALUE("13 January 0030"), 10971);
3111-assertEquals(DATEVALUE("13 January 1200"), -255656);
3112-assertEquals(DATEVALUE("22 January 2222"), 117631);
3113-assertEquals(DATEVALUE("3 November 4243"), 856071);
3114-assertEquals(DATEVALUE("13 November 0999"), -328765);
3115-assertEquals(DATEVALUE("13 November 1200"), -255351);
3116-assertEquals(DATEVALUE("13 January 0029"), 47131);
3117-assertEquals(DATEVALUE("13 January 0030"), 10971);
3118-assertEquals(DATEVALUE("13 January 0044"), 16084);
3119-assertEquals(DATEVALUE("13 January 0050"), 18276);
3120-assertEquals(DATEVALUE("13 January 0097"), 35443);
3121-assertEquals(DATEVALUE("13 January 0099"), 36173);
3122-assertEquals(DATEVALUE("13 January 0000"), 36538);
3123-assertEquals(DATEVALUE("13 January 0101"), -657057);
3124-assertEquals(DATEVALUE("13 January 0100"), -657422);
3125-assertEquals(DATEVALUE("01 Jan 2017"), 42736);
3126-assertEquals(DATEVALUE("01 Feb 2017"), 42767);
3127-assertEquals(DATEVALUE("01 Mar 2017"), 42795);
3128-assertEquals(DATEVALUE("01 Apr 2017"), 42826);
3129-assertEquals(DATEVALUE("01 May 2017"), 42856);
3130-assertEquals(DATEVALUE("01 Jun 2017"), 42887);
3131-assertEquals(DATEVALUE("01 Jul 2017"), 42917);
3132-assertEquals(DATEVALUE("01 Aug 2017"), 42948);
3133-assertEquals(DATEVALUE("01 Sep 2017"), 42979);
3134-assertEquals(DATEVALUE("01 Oct 2017"), 43009);
3135-assertEquals(DATEVALUE("01 Nov 2017"), 43040);
3136-assertEquals(DATEVALUE(" 1 Dec 2017"), 43070);
3137-assertEquals(DATEVALUE("20 Jan 2015"), 42024);
3138-assertEquals(DATEVALUE("20 Feb 2015"), 42055);
3139-assertEquals(DATEVALUE("20 Mar 2015"), 42083);
3140-assertEquals(DATEVALUE("20 Apr 2015"), 42114);
3141-assertEquals(DATEVALUE("20 May 2015"), 42144);
3142-assertEquals(DATEVALUE("20 Jun 2015"), 42175);
3143-assertEquals(DATEVALUE("20 Jul 2015"), 42205);
3144-assertEquals(DATEVALUE("20 Aug 2015"), 42236);
3145-assertEquals(DATEVALUE("20 Sep 2015"), 42267);
3146-assertEquals(DATEVALUE("20 Oct 2015"), 42297);
3147-assertEquals(DATEVALUE("20 Nov 2015"), 42328);
3148-assertEquals(DATEVALUE("20 Dec 2015"), 42358);
3149-assertEquals(DATEVALUE("29 Feb 2004"), 38046); // leap year, 29th ok
3150-catchAndAssertEquals(function() {
3151-  DATEVALUE("29 Feb 2001");// not leap year, 29th not ok
3152-}, ERRORS.VALUE_ERROR);
3153-catchAndAssertEquals(function() {
3154-  DATEVALUE("32 June 2001");// overload numbers not ok
3155-}, ERRORS.VALUE_ERROR);
3156-// delimiter tests
3157-assertEquals(DATEVALUE("Sun, 09, Feb, 2017"), 42775);
3158-assertEquals(DATEVALUE("Sun, 09/Feb/2017"), 42775);
3159-assertEquals(DATEVALUE("09/Feb/2017"), 42775);
3160-assertEquals(DATEVALUE("09-Feb-2017"), 42775);
3161-assertEquals(DATEVALUE("09.Feb.2017"), 42775);
3162-assertEquals(DATEVALUE("09 Feb/2017"), 42775);
3163-assertEquals(DATEVALUE("09 . Feb . 2017"), 42775);
3164-// If the delimiters don't match the first one should be a space.
3165-catchAndAssertEquals(function() {
3166-  DATEVALUE("09.Feb/2017");
3167-}, ERRORS.VALUE_ERROR);
3168-// Comma delimiters should be followed by spaces.
3169-catchAndAssertEquals(function() {
3170-  DATEVALUE("09,Feb,2017");
3171-}, ERRORS.VALUE_ERROR);
3172-// timestamp tests
3173-assertEquals(DATEVALUE("24/June/1992 10am"), 33779);
3174-assertEquals(DATEVALUE("24/June/1992 10:10"), 33779);
3175-assertEquals(DATEVALUE("24/June/1992 10:10am"), 33779);
3176-assertEquals(DATEVALUE("24/June/1992 10:10:10"), 33779);
3177-assertEquals(DATEVALUE("24/June/1992 10:10:10am"), 33779);
3178-assertEquals(DATEVALUE("24/June/1992  10  am"), 33779);
3179-assertEquals(DATEVALUE("24/June/1992 10: 10 "), 33779);
3180-assertEquals(DATEVALUE("24/June/1992 10: 10 pm"), 33779);
3181-assertEquals(DATEVALUE("24/June/1992 10: 10: 10"), 33779);
3182-assertEquals(DATEVALUE("24/June/1992  10: 10: 10    am   "), 33779);
3183-// MONTHNAME_DAY_YEAR, Month(fd)DD(fd)YYYY, 'Aug 19 2020' ==============================================================
3184-assertEquals(DATEVALUE("Sun Feb 09 2017"), 42775);
3185-assertEquals(DATEVALUE("Sun Feb 9 2017"), 42775);
3186-assertEquals(DATEVALUE("Mon Feb 09 2017"), 42775);
3187-assertEquals(DATEVALUE("Thursday Feb 09 2017"), 42775);
3188-assertEquals(DATEVALUE("Thursday February 09 2017"), 42775);
3189-assertEquals(DATEVALUE("Sun September 01 20"), 44075);
3190-assertEquals(DATEVALUE("Sun, Feb, 09, 2017"), 42775);
3191-assertEquals(DATEVALUE("May 20 1992"), 33744);
3192-assertEquals(DATEVALUE("December 31 100"), -657070);
3193-assertEquals(DATEVALUE("January 13 0030"), 10971);
3194-assertEquals(DATEVALUE("January 13 1200"), -255656);
3195-assertEquals(DATEVALUE("January 22 2222"), 117631);
3196-assertEquals(DATEVALUE("November 3 4243"), 856071);
3197-assertEquals(DATEVALUE("Feb 29 2004"), 38046); // leap year, 29th ok
3198-catchAndAssertEquals(function() {
3199-  DATEVALUE("Feb 29 2001");// not leap year, 29th not ok
3200-}, ERRORS.VALUE_ERROR);
3201-catchAndAssertEquals(function() {
3202-  DATEVALUE("June 32 2001");// overload numbers not ok
3203-}, ERRORS.VALUE_ERROR);
3204-// YEAR_MONTHDIG, YYYY(fd)MM, '1992/06' ================================================================================
3205-assertEquals(DATEVALUE("2017/01"), 42736);
3206-assertEquals(DATEVALUE("2017/02"), 42767);
3207-assertEquals(DATEVALUE("2017/03"), 42795);
3208-assertEquals(DATEVALUE("2017/04"), 42826);
3209-assertEquals(DATEVALUE("2017/05"), 42856);
3210-assertEquals(DATEVALUE("2017/06"), 42887);
3211-assertEquals(DATEVALUE("2017/07"), 42917);
3212-assertEquals(DATEVALUE("2017/08"), 42948);
3213-assertEquals(DATEVALUE("2017/09"), 42979);
3214-assertEquals(DATEVALUE("2017/10"), 43009);
3215-assertEquals(DATEVALUE("2017/11"), 43040);
3216-assertEquals(DATEVALUE("2017/12"), 43070);
3217-assertEquals(DATEVALUE("2017/01"), 42736);
3218-// delimiter tests
3219-assertEquals(DATEVALUE("Thursday 2017/01"), 42736);
3220-assertEquals(DATEVALUE("Thursday, 2017/01"), 42736);
3221-assertEquals(DATEVALUE("2017/01"), 42736);
3222-assertEquals(DATEVALUE("2017-01"), 42736);
3223-assertEquals(DATEVALUE("2017. 01"), 42736);
3224-assertEquals(DATEVALUE("2017 01"), 42736);
3225-assertEquals(DATEVALUE("2017, 01"), 42736);
3226-// Comma and period delimiters should be followed by spaces.
3227-catchAndAssertEquals(function() {
3228-  DATEVALUE("2017,01");
3229-}, ERRORS.VALUE_ERROR);
3230-catchAndAssertEquals(function() {
3231-  DATEVALUE("2017.01");
3232-}, ERRORS.VALUE_ERROR);
3233-// timestamp test
3234-assertEquals(DATEVALUE("2017-01 10am"), 42736);
3235-assertEquals(DATEVALUE("2017-01 10:10"), 42736);
3236-assertEquals(DATEVALUE("2017-01 10:10am"), 42736);
3237-assertEquals(DATEVALUE("2017-01 10:10:10"), 42736);
3238-assertEquals(DATEVALUE("2017-01 10:10:10am"), 42736);
3239-assertEquals(DATEVALUE("2017-01  10  am"), 42736);
3240-assertEquals(DATEVALUE("2017-01 10: 10 "), 42736);
3241-assertEquals(DATEVALUE("2017-01 10: 10 pm"), 42736);
3242-assertEquals(DATEVALUE("2017-01 10: 10: 10"), 42736);
3243-assertEquals(DATEVALUE("2017-01  10: 10: 10    am   "), 42736);
3244-// MONTHDIG_YEAR, MM(fd)YYYY, '06/1992' ================================================================================
3245-assertEquals(DATEVALUE("01/2017"), 42736);
3246-assertEquals(DATEVALUE("02/2017"), 42767);
3247-assertEquals(DATEVALUE("03/2017"), 42795);
3248-assertEquals(DATEVALUE("04/2017"), 42826);
3249-assertEquals(DATEVALUE("05/2017"), 42856);
3250-assertEquals(DATEVALUE("06/2017"), 42887);
3251-assertEquals(DATEVALUE("07/2017"), 42917);
3252-assertEquals(DATEVALUE("08/2017"), 42948);
3253-assertEquals(DATEVALUE("09/2017"), 42979);
3254-assertEquals(DATEVALUE("10/2017"), 43009);
3255-assertEquals(DATEVALUE("11/2017"), 43040);
3256-assertEquals(DATEVALUE("12/2017"), 43070);
3257-// delimiter tests
3258-assertEquals(DATEVALUE("Thursday 01/2017"), 42736);
3259-assertEquals(DATEVALUE("Thursday, 01/2017"), 42736);
3260-assertEquals(DATEVALUE("1/2017"), 42736);
3261-assertEquals(DATEVALUE("01-2017"), 42736);
3262-assertEquals(DATEVALUE("01. 2017"), 42736);
3263-assertEquals(DATEVALUE("01, 2017"), 42736);
3264-// Comma, period delimiters should be followed by spaces.
3265-catchAndAssertEquals(function() {
3266-  DATEVALUE("01,2017");
3267-}, ERRORS.VALUE_ERROR);
3268-catchAndAssertEquals(function() {
3269-  DATEVALUE("01.2017");
3270-}, ERRORS.VALUE_ERROR);
3271-// 0 is not a month
3272-catchAndAssertEquals(function() {
3273-  DATEVALUE("0/2017");
3274-}, ERRORS.VALUE_ERROR);
3275-// timestamp test
3276-assertEquals(DATEVALUE("01-2017 10am"), 42736);
3277-assertEquals(DATEVALUE("01-2017 10:10"), 42736);
3278-assertEquals(DATEVALUE("01-2017 10:10am"), 42736);
3279-assertEquals(DATEVALUE("01-2017 10:10:10"), 42736);
3280-assertEquals(DATEVALUE("01-2017 10:10:10am"), 42736);
3281-assertEquals(DATEVALUE("01-2017  10  am"), 42736);
3282-assertEquals(DATEVALUE("01-2017 10: 10 "), 42736);
3283-assertEquals(DATEVALUE("01-2017 10: 10 pm"), 42736);
3284-assertEquals(DATEVALUE("01-2017 10: 10: 10"), 42736);
3285-assertEquals(DATEVALUE("01-2017  10: 10: 10    am   "), 42736);
3286-// YEAR_MONTHNAME, YYYY(fd)Month, '1992/Aug' ===========================================================================
3287-assertEquals(DATEVALUE("2017 January"), 42736);
3288-assertEquals(DATEVALUE("2017 February"), 42767);
3289-assertEquals(DATEVALUE("2017 March"), 42795);
3290-assertEquals(DATEVALUE("2017 April"), 42826);
3291-assertEquals(DATEVALUE("2017 May"), 42856);
3292-assertEquals(DATEVALUE("2017 June"), 42887);
3293-assertEquals(DATEVALUE("2017 July"), 42917);
3294-assertEquals(DATEVALUE("2017 August"), 42948);
3295-assertEquals(DATEVALUE("2017 September"), 42979);
3296-assertEquals(DATEVALUE("2017 October"), 43009);
3297-assertEquals(DATEVALUE("2017 November"), 43040);
3298-assertEquals(DATEVALUE("2017 December"), 43070);
3299-// delimiter tests
3300-assertEquals(DATEVALUE("Thursday 2017 January"), 42736);
3301-assertEquals(DATEVALUE("Thursday, 2017 January"), 42736);
3302-assertEquals(DATEVALUE("2017/January"), 42736);
3303-assertEquals(DATEVALUE("2017-January"), 42736);
3304-assertEquals(DATEVALUE("2017. January"), 42736);
3305-assertEquals(DATEVALUE("2017, January"), 42736);
3306-// Comma delimiters should be followed by spaces.
3307-catchAndAssertEquals(function() {
3308-  DATEVALUE("2017,January");
3309-}, ERRORS.VALUE_ERROR);
3310-catchAndAssertEquals(function() {
3311-  DATEVALUE("2017.January");
3312-}, ERRORS.VALUE_ERROR);
3313-// timestamp test
3314-assertEquals(DATEVALUE("2017-January 10am"), 42736);
3315-assertEquals(DATEVALUE("2017-January 10:10"), 42736);
3316-assertEquals(DATEVALUE("2017-January 10:10am"), 42736);
3317-assertEquals(DATEVALUE("2017-January 10:10:10"), 42736);
3318-assertEquals(DATEVALUE("2017-January 10:10:10am"), 42736);
3319-assertEquals(DATEVALUE("2017-January  10  am"), 42736);
3320-assertEquals(DATEVALUE("2017-January 10: 10 "), 42736);
3321-assertEquals(DATEVALUE("2017-January 10: 10 pm"), 42736);
3322-assertEquals(DATEVALUE("2017-January 10: 10: 10"), 42736);
3323-assertEquals(DATEVALUE("2017-January  10: 10: 10    am   "), 42736);
3324-// MONTHNAME_YEAR, Month(fd)YYYY, 'Aug 1992' ===========================================================================
3325-assertEquals(DATEVALUE("January 2017"), 42736);
3326-assertEquals(DATEVALUE("February 2017"), 42767);
3327-assertEquals(DATEVALUE("March 2017"), 42795);
3328-assertEquals(DATEVALUE("April 2017"), 42826);
3329-assertEquals(DATEVALUE("May 2017"), 42856);
3330-assertEquals(DATEVALUE("June 2017"), 42887);
3331-assertEquals(DATEVALUE("July 2017"), 42917);
3332-assertEquals(DATEVALUE("August 2017"), 42948);
3333-assertEquals(DATEVALUE("September 2017"), 42979);
3334-assertEquals(DATEVALUE("October 2017"), 43009);
3335-assertEquals(DATEVALUE("November 2017"), 43040);
3336-assertEquals(DATEVALUE("December 2017"), 43070);
3337-assertEquals(DATEVALUE("  Feb    2017  "), 42767);
3338-assertEquals(DATEVALUE("Feb-2017"), 42767);
3339-assertEquals(DATEVALUE("Feb. 2017"), 42767);
3340-assertEquals(DATEVALUE("Feb/2017"), 42767);
3341-assertEquals(DATEVALUE("Feb    .    2017"), 42767);
3342-assertEquals(DATEVALUE("Feb -      2017"), 42767);
3343-assertEquals(DATEVALUE("January 0030"), 10959);
3344-assertEquals(DATEVALUE("November 4243"), 856069);
3345-assertEquals(DATEVALUE("December 0100"), -657100);
3346-assertEquals(DATEVALUE("Jan 2017"), 42736);
3347-assertEquals(DATEVALUE("Feb 2017"), 42767);
3348-assertEquals(DATEVALUE("Mar 2017"), 42795);
3349-assertEquals(DATEVALUE("Apr 2017"), 42826);
3350-assertEquals(DATEVALUE("May 2017"), 42856);
3351-assertEquals(DATEVALUE("Jun 2017"), 42887);
3352-assertEquals(DATEVALUE("Jul 2017"), 42917);
3353-assertEquals(DATEVALUE("Aug 2017"), 42948);
3354-assertEquals(DATEVALUE("Sep 2017"), 42979);
3355-assertEquals(DATEVALUE("Oct 2017"), 43009);
3356-assertEquals(DATEVALUE("Nov 2017"), 43040);
3357-assertEquals(DATEVALUE("Dec 2017"), 43070);
3358-assertEquals(DATEVALUE("Feb, 2017"), 42767);
3359-catchAndAssertEquals(function() {
3360-  DATEVALUE("December 100");// need 4 digits
3361-}, ERRORS.VALUE_ERROR);
3362-catchAndAssertEquals(function() {
3363-  DATEVALUE("Dec.20");// need space after if using period
3364-}, ERRORS.VALUE_ERROR);
3365-// delimiter tests
3366-assertEquals(DATEVALUE("Thursday January 2017"), 42736);
3367-assertEquals(DATEVALUE("Thursday, January 2017"), 42736);
3368-assertEquals(DATEVALUE("January/2017"), 42736);
3369-assertEquals(DATEVALUE("January-2017"), 42736);
3370-assertEquals(DATEVALUE("January. 2017"), 42736);
3371-assertEquals(DATEVALUE("January, 2017"), 42736);
3372-// Comma, period delimiters should be followed by spaces.
3373-catchAndAssertEquals(function() {
3374-  DATEVALUE("January,2017");
3375-}, ERRORS.VALUE_ERROR);
3376-catchAndAssertEquals(function() {
3377-  DATEVALUE("January.2017");
3378-}, ERRORS.VALUE_ERROR);
3379-// timestamp test
3380-assertEquals(DATEVALUE("January-2017 10am"), 42736);
3381-assertEquals(DATEVALUE("January-2017 10:10"), 42736);
3382-assertEquals(DATEVALUE("January-2017 10:10am"), 42736);
3383-assertEquals(DATEVALUE("January-2017 10:10:10"), 42736);
3384-assertEquals(DATEVALUE("January-2017 10:10:10am"), 42736);
3385-assertEquals(DATEVALUE("January-2017  10  am"), 42736);
3386-assertEquals(DATEVALUE("January-2017 10: 10 "), 42736);
3387-assertEquals(DATEVALUE("January-2017 10: 10 pm"), 42736);
3388-assertEquals(DATEVALUE("January-2017 10: 10: 10"), 42736);
3389-assertEquals(DATEVALUE("January-2017  10: 10: 10    am  "), 42736);
3390+test("DATEVALUE", function(){
3391+  assertEquals(DATEVALUE("6/24/92"), 33779);
3392+  assertEquals(DATEVALUE(["6/24/92", false]), 33779);
3393+  catchAndAssertEquals(function() {
3394+    DATEVALUE("6/24/92", 10);
3395+  }, ERRORS.NA_ERROR);
3396+  catchAndAssertEquals(function() {
3397+    DATEVALUE();
3398+  }, ERRORS.NA_ERROR);
3399+  catchAndAssertEquals(function() {
3400+    DATEVALUE(false);
3401+  }, ERRORS.VALUE_ERROR);
3402+  // MONTHDIG_DAY_YEAR, MM(fd)DD(fd)YYYY ===============================================================================
3403+  assertEquals(DATEVALUE("6/24/92"), 33779);
3404+  assertEquals(DATEVALUE("6/24/1992"), 33779);
3405+  assertEquals(DATEVALUE("06/24/1992"), 33779);
3406+  assertEquals(DATEVALUE("1/01/1999"), 36161);
3407+  assertEquals(DATEVALUE("1/01/99"), 36161);
3408+  assertEquals(DATEVALUE("1/01/2222"), 117610);
3409+  assertEquals(DATEVALUE("9/02/1902"), 976);
3410+  assertEquals(DATEVALUE("9/2/1902"), 976);
3411+  assertEquals(DATEVALUE("11/3/4243"), 856071);
3412+  assertEquals(DATEVALUE("  04/19/1992  "), 33713);
3413+  assertEquals(DATEVALUE("5/20/1992"), 33744);
3414+  assertEquals(DATEVALUE("6/21/1992"), 33776);
3415+  assertEquals(DATEVALUE("9/29/1992"), 33876);
3416+  assertEquals(DATEVALUE("1/24/1992"), 33627);
3417+  assertEquals(DATEVALUE("12/21/1992"), 33959);
3418+  assertEquals(DATEVALUE("01/31/1992"), 33634);
3419+  assertEquals(DATEVALUE("1/13/1992"), 33616);
3420+  assertEquals(DATEVALUE("2/29/2004"), 38046);
3421+  assertEquals(DATEVALUE("2/28/2004"), 38045);
3422+  assertEquals(DATEVALUE("2/28/004"), 38045);
3423+  assertEquals(DATEVALUE("2/28/04"), 38045);
3424+  assertEquals(DATEVALUE("2/28/4"), 38045);
3425+  assertEquals(DATEVALUE("1/13/1999"), 36173);
3426+  assertEquals(DATEVALUE("01/13/1999"), 36173);
3427+  assertEquals(DATEVALUE("01/13/0999"), -329069);
3428+  assertEquals(DATEVALUE("01/13/1200"), -255656);
3429+  assertEquals(DATEVALUE("01/13/0029"), 47131);
3430+  assertEquals(DATEVALUE("01/13/0030"), 10971);
3431+  assertEquals(DATEVALUE("01/13/0044"), 16084);
3432+  assertEquals(DATEVALUE("01/13/0050"), 18276);
3433+  assertEquals(DATEVALUE("01/13/0097"), 35443);
3434+  assertEquals(DATEVALUE("01/13/0099"), 36173);
3435+  assertEquals(DATEVALUE("01/13/0000"), 36538);
3436+  assertEquals(DATEVALUE("01/13/0101"), -657057);
3437+  assertEquals(DATEVALUE("01/13/0100"), -657422);
3438+  assertEquals(DATEVALUE("12/31/100"), -657070);
3439+  assertEquals(DATEVALUE("11/10/122"), -649086);
3440+  assertEquals(DATEVALUE("1/22/2222"), 117631);
3441+  assertEquals(DATEVALUE("1/22/222"), -612854);
3442+  // delimiter tests
3443+  assertEquals(DATEVALUE("6-24-92"), 33779);
3444+  assertEquals(DATEVALUE("6/24/92"), 33779);
3445+  assertEquals(DATEVALUE("6 24 92"), 33779);
3446+  assertEquals(DATEVALUE("6.24.92"), 33779);
3447+  assertEquals(DATEVALUE("6 . 24 . 92"), 33779);
3448+  assertEquals(DATEVALUE("6 / 24 / 92"), 33779);
3449+  assertEquals(DATEVALUE("6, 24, 92"), 33779);
3450+  // flex delimiter should not allow a comma without a space after it.
3451+  catchAndAssertEquals(function() {
3452+    DATEVALUE("Sunday,6/24/92");
3453+  }, ERRORS.VALUE_ERROR);
3454+  // Leap day on non-leap years
3455+  catchAndAssertEquals(function() {
3456+    DATEVALUE("2/29/2005");
3457+  }, ERRORS.VALUE_ERROR);
3458+  catchAndAssertEquals(function() {
3459+    DATEVALUE("2/29/2001");
3460+  }, ERRORS.VALUE_ERROR);
3461+  // Out of range day for any month
3462+  catchAndAssertEquals(function() {
3463+    DATEVALUE("1/44/2005");
3464+  }, ERRORS.VALUE_ERROR);
3465+  // timestamp test
3466+  assertEquals(DATEVALUE("6-24-92 10am"), 33779);
3467+  assertEquals(DATEVALUE("6-24-92 10:10"), 33779);
3468+  assertEquals(DATEVALUE("6-24-92 10:10am"), 33779);
3469+  assertEquals(DATEVALUE("6-24-92 10:10:10"), 33779);
3470+  assertEquals(DATEVALUE("6-24-92 10:10:10am"), 33779);
3471+  assertEquals(DATEVALUE("6-24-92  10  am"), 33779);
3472+  assertEquals(DATEVALUE("6-24-92 10: 10 "), 33779);
3473+  assertEquals(DATEVALUE("6-24-92 10: 10 pm"), 33779);
3474+  assertEquals(DATEVALUE("6-24-92 10: 10: 10"), 33779);
3475+  assertEquals(DATEVALUE("6-24-92  10: 10: 10    am  "), 33779);
3476+  assertEquals(DATEVALUE("1992/6/24 00:00"), 33779);
3477+  assertEquals(DATEVALUE("1992/6/24 0:00"), 33779);
3478+  assertEquals(DATEVALUE("1992/6/24 10:10"), 33779);
3479+  assertEquals(DATEVALUE("1992/6/24 16:22"), 33779);
3480+  assertEquals(DATEVALUE("1992/6/24 25:10"), 33780);
3481+  assertEquals(DATEVALUE("1992/6/24 23:60"), 33780);
3482+  assertEquals(DATEVALUE("1992/6/24 24:00"), 33780);
3483+  assertEquals(DATEVALUE("1992/6/24 23:59"), 33779);
3484+  assertEquals(DATEVALUE("1999/1/13 10:11111111"), 43889);
3485+  assertEquals(DATEVALUE("1999/1/13 25000:22"), 37214);
3486+  assertEquals(DATEVALUE("1999/1/13 25000:    22"), 37214);
3487+  assertEquals(DATEVALUE("1992/6/24 00:00am"), 33779);
3488+  assertEquals(DATEVALUE("1992/06/24 01:44am "), 33779);
3489+  assertEquals(DATEVALUE("1999/1/01 02:59pm"), 36161);
3490+  assertEquals(DATEVALUE("2222/1/01 03:33pm"), 117610);
3491+  assertEquals(DATEVALUE("1902/9/02 12:33pm"), 976);
3492+  assertEquals(DATEVALUE("1902/9/2 12:33pm"), 976);
3493+  assertEquals(DATEVALUE("4243/11/3 12:33pm"), 856071);
3494+  assertEquals(DATEVALUE("  1992/04/19   12:  33pm   "), 33713);
3495+  assertEquals(DATEVALUE("1992/5/20 01:33am"), 33744);
3496+  assertEquals(DATEVALUE("1992/6/21  3:33pm"), 33776);
3497+  assertEquals(DATEVALUE("1992/9/29 3:33pm"), 33876);
3498+  assertEquals(DATEVALUE("1992/1/24 3:33pm"), 33627);
3499+  assertEquals(DATEVALUE("1992/12/21 3:33pm"), 33959);
3500+  assertEquals(DATEVALUE("1992/01/31 3:33pm"), 33634);
3501+  assertEquals(DATEVALUE("1992/1/13 3:33pm"), 33616);
3502+  assertEquals(DATEVALUE("2004/2/29 3:33pm"), 38046);
3503+  assertEquals(DATEVALUE("2004/2/28  3:33pm "), 38045);
3504+  assertEquals(DATEVALUE("1999/1/13 3:33pm"), 36173);
3505+  assertEquals(DATEVALUE("1999/01/13 3:33pm"), 36173);
3506+  assertEquals(DATEVALUE("0999/01/13 3:33pm"), -329069);
3507+  assertEquals(DATEVALUE("1200/01/13 3:33pm"), -255656);
3508+  assertEquals(DATEVALUE("0029/01/13 3:33pm"), 47131);
3509+  assertEquals(DATEVALUE("0030/01/13 3:33pm"), 10971);
3510+  assertEquals(DATEVALUE("0044/01/13 3:33pm"), 16084);
3511+  assertEquals(DATEVALUE("0050/01/13 3:33pm"), 18276);
3512+  assertEquals(DATEVALUE("0097/01/13 00:33pm"), 35443);
3513+  assertEquals(DATEVALUE("0099/01/13 3:33pm"), 36173);
3514+  assertEquals(DATEVALUE("0000/01/13 3:33pm"), 36538);
3515+  assertEquals(DATEVALUE("0101/01/13 3:33pm"), -657057);
3516+  assertEquals(DATEVALUE("0100/01/13 3:33pm"), -657422);
3517+  assertEquals(DATEVALUE("100/12/31 3:33pm"), -657070);
3518+  assertEquals(DATEVALUE("122/11/10 3:33pm"), -649086);
3519+  assertEquals(DATEVALUE("2222/1/22 3:33pm"), 117631);
3520+  assertEquals(DATEVALUE("222/1/22 3:33pm"), -612854);
3521+  assertEquals(DATEVALUE("1992/1/13 6:22222222am"), 49048); // overload minutes
3522+  assertEquals(DATEVALUE("1992/1/13 12:720pm"), 33617); // overload minutes
3523+  assertEquals(DATEVALUE("1992/1/13 00:720pm"), 33617); // overload minutes
3524+  assertEquals(DATEVALUE("1992/1/13 12:719pm"), 33616); // overload minutes
3525+  assertEquals(DATEVALUE("1992/1/13 00:720am"), 33616); // overload minutes
3526+  assertEquals(DATEVALUE("1992/1/13 00:01pm"), 33616); // overload minutes
3527+  assertEquals(DATEVALUE("1992/1/13 12:66669pm"), 33662); // overload minutes
3528+  assertEquals(DATEVALUE("1992/1/13 12:66669am"), 33662); // overload minutes
3529+  assertEquals(DATEVALUE("1992/1/13 12:66249pm"), 33662); // overload minutes
3530+  assertEquals(DATEVALUE("1992/1/13 12:66249am"), 33662); // overload minutes
3531+  assertEquals(DATEVALUE("1992/1/13 12:666669am"), 34078); // overload minutes
3532+  assertEquals(DATEVALUE("1992/1/13 12:666669pm"), 34079); // overload minutes
3533+  assertEquals(DATEVALUE("1992/1/13 12:100000000am"), 103060); // overload minutes
3534+  assertEquals(DATEVALUE("1992/1/13 12:0912347287am"), 667190); // overload minutes
3535+  assertEquals(DATEVALUE("1992/1/13 12:00000912347287am"), 667190); // overload minutes
3536+  assertEquals(DATEVALUE("1992/1/13 12:1989198298am"), 1415003); // overload minutes
3537+  assertEquals(DATEVALUE("1992/6/24 0:0:0"), 33779);
3538+  assertEquals(DATEVALUE("1992/6/24 0000:0000:0000"), 33779);
3539+  assertEquals(DATEVALUE("0000/01/13 3:33:999999999"), 48112); // overload seconds
3540+  assertEquals(DATEVALUE("1992/1/13 6:22222222:0"), 49048); // overload minutes
3541+  assertEquals(DATEVALUE("1992/1/13 12:912347287:10"), 667191); // overload minutes
3542+  assertEquals(DATEVALUE("1992/1/13 12:100000000:10"), 103060); // overload minutes
3543+  assertEquals(DATEVALUE("1992/1/13 23:720:10"), 33617); // overload minutes
3544+  assertEquals(DATEVALUE("1992/1/13 23:719:60"), 33617); // overload minutes, seconds
3545+  assertEquals(DATEVALUE("1992/6/24 24:00:00"), 33780); // overload hours
3546+  assertEquals(DATEVALUE("1999/1/01 200000000:999999999:923231312"), 9074624); // overload hours, minutes, seconds
3547+  assertEquals(DATEVALUE("  1992/04/19   12:  33: 11  "), 33713);
3548+  assertEquals(DATEVALUE("0000/01/13 3:33:33"), 36538);
3549+  assertEquals(DATEVALUE("4243/11/3 200000000:33:444"), 9189404);
3550+  assertEquals(DATEVALUE("1999/1/13 10:10:10pm"), 36173);
3551+  assertEquals(DATEVALUE("1992/6/24 0:0:0pm"), 33779);
3552+  assertEquals(DATEVALUE("1992/6/24 00:0000:0000pm"), 33779);
3553+  assertEquals(DATEVALUE("0000/01/13 3:33:999999999pm"), 48112); // overload seconds
3554+  assertEquals(DATEVALUE("1992/1/13 6:22222222:0pm"), 49048); // overload minutes
3555+  assertEquals(DATEVALUE("1992/1/13 12:912347287:10pm"), 667191); // overload minutes
3556+  assertEquals(DATEVALUE("1992/1/13 12:100000000:10pm"), 103060); // overload minutes
3557+  assertEquals(DATEVALUE("1992/6/24 00:00:00am"), 33779);
3558+  assertEquals(DATEVALUE("1992/06/24 01:44:00am "), 33779);
3559+  assertEquals(DATEVALUE("1999/1/01 02:59:00pm"), 36161);
3560+  assertEquals(DATEVALUE("2222/1/01 03:33:00pm"), 117610);
3561+  assertEquals(DATEVALUE("1902/9/02 12:33:00pm"), 976);
3562+  assertEquals(DATEVALUE("1902/9/2 12:33:00pm"), 976);
3563+  assertEquals(DATEVALUE("4243/11/3 12:33:00pm"), 856071);
3564+  assertEquals(DATEVALUE("  1992/04/19   12:  33:  00  pm   "), 33713);
3565+  assertEquals(DATEVALUE("1992/5/20 01:33:44am"), 33744);
3566+  assertEquals(DATEVALUE("1992/6/21  3:33:44pm"), 33776);
3567+  assertEquals(DATEVALUE("1992/9/29 3:33:44pm"), 33876);
3568+  assertEquals(DATEVALUE("1992/1/24 3:33:44pm"), 33627);
3569+  assertEquals(DATEVALUE("1992/12/21 3:33:44pm"), 33959);
3570+  assertEquals(DATEVALUE("1992/01/31 3:33:44pm"), 33634);
3571+  assertEquals(DATEVALUE("1992/1/13 3:33:44pm"), 33616);
3572+  assertEquals(DATEVALUE("2004/2/29 3:33:44pm"), 38046);
3573+  assertEquals(DATEVALUE("2004/2/28  3:33:44pm "), 38045);
3574+  assertEquals(DATEVALUE("1999/1/13 3:33:44pm"), 36173);
3575+  assertEquals(DATEVALUE("1999/01/13 3:33:44pm"), 36173);
3576+  assertEquals(DATEVALUE("0999/01/13 3:33:44pm"), -329069);
3577+  assertEquals(DATEVALUE("1200/01/13 3:33:44pm"), -255656);
3578+  assertEquals(DATEVALUE("0029/01/13 3:33:44pm"), 47131);
3579+  assertEquals(DATEVALUE("0030/01/13 3:33:44pm"), 10971);
3580+  assertEquals(DATEVALUE("0044/01/13 3:33:44pm"), 16084);
3581+  assertEquals(DATEVALUE("0050/01/13 3:33:44pm"), 18276);
3582+  assertEquals(DATEVALUE("0097/01/13 00:33:44pm"), 35443);
3583+  assertEquals(DATEVALUE("0099/01/13 3:33:44pm"), 36173);
3584+  assertEquals(DATEVALUE("0000/01/13 3:33:44pm"), 36538);
3585+  assertEquals(DATEVALUE("0101/01/13 3:33:44pm"), -657057);
3586+  assertEquals(DATEVALUE("0100/01/13 3:33:44pm"), -657422);
3587+  assertEquals(DATEVALUE("100/12/31 3:33:44pm"), -657070);
3588+  assertEquals(DATEVALUE("122/11/10 3:33:44pm"), -649086);
3589+  assertEquals(DATEVALUE("2222/1/22 3:33:44pm"), 117631);
3590+  assertEquals(DATEVALUE("222/1/22 3:33:44pm"), -612854);
3591+  assertEquals(DATEVALUE("1992/1/13 6:22222222:44am"), 49048); // overload minutes
3592+  assertEquals(DATEVALUE("1992/1/13 12:720:00pm"), 33617); // overload minutes
3593+  assertEquals(DATEVALUE("1992/1/13 00:720:00pm"), 33617); // overload minutes
3594+  assertEquals(DATEVALUE("1992/1/13 12:719:00pm"), 33616); // overload minutes
3595+  assertEquals(DATEVALUE("1992/1/13 00:720:00am"), 33616); // overload minutes
3596+  assertEquals(DATEVALUE("1992/1/13 12:719:60pm"), 33617); // overload minutes
3597+  assertEquals(DATEVALUE("1992/1/13 00:720:00am"), 33616); // overload minutes
3598+  assertEquals(DATEVALUE("1992/1/13 00:01:00pm"), 33616); // overload minutes
3599+  assertEquals(DATEVALUE("1992/1/13 12:66669:00pm"), 33662); // overload minutes
3600+  assertEquals(DATEVALUE("1992/1/13 12:66669:00am"), 33662); // overload minutes
3601+  assertEquals(DATEVALUE("1992/1/13 12:66249:00pm"), 33662); // overload minutes
3602+  assertEquals(DATEVALUE("1992/1/13 12:66249:00am"), 33662); // overload minutes
3603+  assertEquals(DATEVALUE("1992/1/13 12:666669:00am"), 34078); // overload minutes
3604+  assertEquals(DATEVALUE("1992/1/13 12:666669:00pm"), 34079); // overload minutes
3605+  assertEquals(DATEVALUE("1992/1/13 12:100000000:00am"), 103060); // overload minutes
3606+  assertEquals(DATEVALUE("1992/1/13 12:912347287:00am"), 667190); // overload minutes
3607+  // YEAR_MONTHDIG_DAY, YYYY(fd)MM(fd)DD ===============================================================================
3608+  assertEquals(DATEVALUE("1992/6/24"), 33779);
3609+  assertEquals(DATEVALUE("1992/06/24"), 33779);
3610+  assertEquals(DATEVALUE("1999/1/01"), 36161);
3611+  assertEquals(DATEVALUE("2222/1/01"), 117610);
3612+  assertEquals(DATEVALUE("1902/9/02"), 976);
3613+  assertEquals(DATEVALUE("1902/9/2"), 976);
3614+  assertEquals(DATEVALUE("4243/11/3"), 856071);
3615+  assertEquals(DATEVALUE("  1992/04/19  "), 33713);
3616+  assertEquals(DATEVALUE("  1992 /  04/ 19  "), 33713);
3617+  assertEquals(DATEVALUE("1992/5/20"), 33744);
3618+  assertEquals(DATEVALUE("1992/6/21"), 33776);
3619+  assertEquals(DATEVALUE("1992/9/29"), 33876);
3620+  assertEquals(DATEVALUE("1992/1/24"), 33627);
3621+  assertEquals(DATEVALUE("1992/12/21"), 33959);
3622+  assertEquals(DATEVALUE("1992/01/31"), 33634);
3623+  assertEquals(DATEVALUE("1992/1/13"), 33616);
3624+  assertEquals(DATEVALUE("2004/2/29"), 38046);
3625+  assertEquals(DATEVALUE("2004/2/28"), 38045);
3626+  assertEquals(DATEVALUE("1999/1/13"), 36173);
3627+  assertEquals(DATEVALUE("1999/01/13"), 36173);
3628+  assertEquals(DATEVALUE("0999/01/13"), -329069);
3629+  assertEquals(DATEVALUE("1200/01/13"), -255656);
3630+  assertEquals(DATEVALUE("0029/01/13"), 47131);
3631+  assertEquals(DATEVALUE("0030/01/13"), 10971);
3632+  assertEquals(DATEVALUE("0044/01/13"), 16084);
3633+  assertEquals(DATEVALUE("0050/01/13"), 18276);
3634+  assertEquals(DATEVALUE("0097/01/13"), 35443);
3635+  assertEquals(DATEVALUE("0099/01/13"), 36173);
3636+  assertEquals(DATEVALUE("0000/01/13"), 36538);
3637+  assertEquals(DATEVALUE("0101/01/13"), -657057);
3638+  assertEquals(DATEVALUE("0100/01/13"), -657422);
3639+  assertEquals(DATEVALUE("100/12/31"), -657070);
3640+  assertEquals(DATEVALUE("122/11/10"), -649086);
3641+  assertEquals(DATEVALUE("2222/1/22"), 117631);
3642+  assertEquals(DATEVALUE("222/1/22"), -612854);
3643+  assertEquals(DATEVALUE("Sunday 1992/6/24"), 33779);
3644+  assertEquals(DATEVALUE("Monday 1992/6/24"), 33779);
3645+  assertEquals(DATEVALUE("Tuesday 1992/6/24"), 33779);
3646+  assertEquals(DATEVALUE("Wednesday 1992/6/24"), 33779);
3647+  assertEquals(DATEVALUE("Thursday 1992/6/24"), 33779);
3648+  assertEquals(DATEVALUE("Friday 1992/6/24"), 33779);
3649+  assertEquals(DATEVALUE("Saturday 1992/6/24"), 33779);
3650+  assertEquals(DATEVALUE("Sun 1992/6/24"), 33779);
3651+  assertEquals(DATEVALUE("Mon 1992/6/24"), 33779);
3652+  assertEquals(DATEVALUE("Tue 1992/6/24"), 33779);
3653+  assertEquals(DATEVALUE("Wed 1992/6/24"), 33779);
3654+  assertEquals(DATEVALUE("Thu 1992/6/24"), 33779);
3655+  assertEquals(DATEVALUE("Fri 1992/6/24"), 33779);
3656+  assertEquals(DATEVALUE("Sat 1992/6/24"), 33779);
3657+  assertEquals(DATEVALUE("Sunday, 1992/6/24"), 33779);
3658+  // delimiter tests
3659+  assertEquals(DATEVALUE("1992-6-24"), 33779);
3660+  assertEquals(DATEVALUE("1992/6/24"), 33779);
3661+  assertEquals(DATEVALUE("1992 6 24"), 33779);
3662+  assertEquals(DATEVALUE("1992 6 24"), 33779);
3663+  assertEquals(DATEVALUE("1992 . 6 . 24"), 33779);
3664+  assertEquals(DATEVALUE("1992 / 6 / 24"), 33779);
3665+  assertEquals(DATEVALUE("1992, 6, 24"), 33779);
3666+  // flex delimiter should not allow a comma without a space after it.
3667+  catchAndAssertEquals(function() {
3668+    DATEVALUE("Sunday,1992/6/24");
3669+  }, ERRORS.VALUE_ERROR);
3670+  // Leap day on non-leap years
3671+  catchAndAssertEquals(function() {
3672+    DATEVALUE("2005/2/29");
3673+  }, ERRORS.VALUE_ERROR);
3674+  catchAndAssertEquals(function() {
3675+    DATEVALUE("2001/2/29");
3676+  }, ERRORS.VALUE_ERROR);
3677+  // Out of range day for any month
3678+  catchAndAssertEquals(function() {
3679+    DATEVALUE("2005/1/44");
3680+  }, ERRORS.VALUE_ERROR);
3681+  // timestamp test
3682+  assertEquals(DATEVALUE("1992-6-24 10am"), 33779);
3683+  assertEquals(DATEVALUE("1992-6-24 10:10"), 33779);
3684+  assertEquals(DATEVALUE("1992-6-24 10:10am"), 33779);
3685+  assertEquals(DATEVALUE("1992-6-24 10:10:10"), 33779);
3686+  assertEquals(DATEVALUE("1992-6-24 10:10:10am"), 33779);
3687+  assertEquals(DATEVALUE("1992-6-24  10  am"), 33779);
3688+  assertEquals(DATEVALUE("1992-6-24 10: 10 "), 33779);
3689+  assertEquals(DATEVALUE("1992-6-24 10: 10 pm"), 33779);
3690+  assertEquals(DATEVALUE("1992-6-24 10: 10: 10"), 33779);
3691+  assertEquals(DATEVALUE("1992-6-24  10: 10: 10    am   "), 33779);
3692+  assertEquals(DATEVALUE("1992/6/24 00am"), 33779);
3693+  assertEquals(DATEVALUE("1992/06/24 01am "), 33779);
3694+  assertEquals(DATEVALUE("1999/1/01 02pm"), 36161);
3695+  assertEquals(DATEVALUE("2222/1/01 03pm"), 117610);
3696+  assertEquals(DATEVALUE("1902/9/02 12pm"), 976);
3697+  assertEquals(DATEVALUE("1902/9/2 12pm"), 976);
3698+  assertEquals(DATEVALUE("4243/11/3 12pm   "), 856071);
3699+  assertEquals(DATEVALUE("  1992/04/19   12pm   "), 33713);
3700+  assertEquals(DATEVALUE("1992/5/20 01am"), 33744);
3701+  assertEquals(DATEVALUE("1992/6/21  3pm"), 33776);
3702+  assertEquals(DATEVALUE("1992/9/29 3pm"), 33876);
3703+  assertEquals(DATEVALUE("1992/1/24 3pm"), 33627);
3704+  assertEquals(DATEVALUE("1992/12/21 3pm"), 33959);
3705+  assertEquals(DATEVALUE("1992/01/31 3pm"), 33634);
3706+  assertEquals(DATEVALUE("1992/1/13 3pm"), 33616);
3707+  assertEquals(DATEVALUE("2004/2/29 3pm"), 38046);
3708+  assertEquals(DATEVALUE("2004/2/28  3pm "), 38045);
3709+  assertEquals(DATEVALUE("1999/1/13 3pm"), 36173);
3710+  assertEquals(DATEVALUE("1999/01/13 3pm"), 36173);
3711+  assertEquals(DATEVALUE("0999/01/13 3pm"), -329069);
3712+  assertEquals(DATEVALUE("1200/01/13 3pm"), -255656);
3713+  assertEquals(DATEVALUE("0029/01/13 3pm"), 47131);
3714+  assertEquals(DATEVALUE("0030/01/13 3pm"), 10971);
3715+  assertEquals(DATEVALUE("0044/01/13 3pm"), 16084);
3716+  assertEquals(DATEVALUE("0050/01/13 3pm"), 18276);
3717+  assertEquals(DATEVALUE("0097/01/13 00pm"), 35443);
3718+  assertEquals(DATEVALUE("0099/01/13 3pm"), 36173);
3719+  assertEquals(DATEVALUE("0000/01/13 3pm"), 36538);
3720+  assertEquals(DATEVALUE("0101/01/13 3pm"), -657057);
3721+  assertEquals(DATEVALUE("0100/01/13 3pm"), -657422);
3722+  assertEquals(DATEVALUE("100/12/31 3pm"), -657070);
3723+  assertEquals(DATEVALUE("122/11/10 3pm"), -649086);
3724+  assertEquals(DATEVALUE("2222/1/22 3pm"), 117631);
3725+  assertEquals(DATEVALUE("222/1/22 3pm"), -612854);
3726+  catchAndAssertEquals(function() {
3727+    DATEVALUE("2005/2/29 000pm");// Too many digits
3728+  }, ERRORS.VALUE_ERROR);
3729+  catchAndAssertEquals(function() {
3730+    DATEVALUE("2001/2/2 13pm");// Hour out of range
3731+  }, ERRORS.VALUE_ERROR);
3732+  // DAY_MONTHNAME_YEAR, DD(fd)Month(fd)YYYY ===========================================================================
3733+  assertEquals(DATEVALUE("Sun 09 Feb 2017"), 42775);
3734+  assertEquals(DATEVALUE("Sun 9 Feb 2017"), 42775);
3735+  assertEquals(DATEVALUE("Mon 09 Feb 2017"), 42775);
3736+  assertEquals(DATEVALUE("Thursday 09 Feb 2017"), 42775);
3737+  assertEquals(DATEVALUE("Thursday 09 February 2017"), 42775);
3738+  assertEquals(DATEVALUE("Sun 01 September 20"), 44075);
3739+  assertEquals(DATEVALUE("Sun, 09, Feb, 2017"), 42775);
3740+  assertEquals(DATEVALUE("20 May 1992"), 33744);
3741+  assertEquals(DATEVALUE("31 December 100"), -657070);
3742+  assertEquals(DATEVALUE("13 January 0030"), 10971);
3743+  assertEquals(DATEVALUE("13 January 1200"), -255656);
3744+  assertEquals(DATEVALUE("22 January 2222"), 117631);
3745+  assertEquals(DATEVALUE("3 November 4243"), 856071);
3746+  assertEquals(DATEVALUE("13 November 0999"), -328765);
3747+  assertEquals(DATEVALUE("13 November 1200"), -255351);
3748+  assertEquals(DATEVALUE("13 January 0029"), 47131);
3749+  assertEquals(DATEVALUE("13 January 0030"), 10971);
3750+  assertEquals(DATEVALUE("13 January 0044"), 16084);
3751+  assertEquals(DATEVALUE("13 January 0050"), 18276);
3752+  assertEquals(DATEVALUE("13 January 0097"), 35443);
3753+  assertEquals(DATEVALUE("13 January 0099"), 36173);
3754+  assertEquals(DATEVALUE("13 January 0000"), 36538);
3755+  assertEquals(DATEVALUE("13 January 0101"), -657057);
3756+  assertEquals(DATEVALUE("13 January 0100"), -657422);
3757+  assertEquals(DATEVALUE("01 Jan 2017"), 42736);
3758+  assertEquals(DATEVALUE("01 Feb 2017"), 42767);
3759+  assertEquals(DATEVALUE("01 Mar 2017"), 42795);
3760+  assertEquals(DATEVALUE("01 Apr 2017"), 42826);
3761+  assertEquals(DATEVALUE("01 May 2017"), 42856);
3762+  assertEquals(DATEVALUE("01 Jun 2017"), 42887);
3763+  assertEquals(DATEVALUE("01 Jul 2017"), 42917);
3764+  assertEquals(DATEVALUE("01 Aug 2017"), 42948);
3765+  assertEquals(DATEVALUE("01 Sep 2017"), 42979);
3766+  assertEquals(DATEVALUE("01 Oct 2017"), 43009);
3767+  assertEquals(DATEVALUE("01 Nov 2017"), 43040);
3768+  assertEquals(DATEVALUE(" 1 Dec 2017"), 43070);
3769+  assertEquals(DATEVALUE("20 Jan 2015"), 42024);
3770+  assertEquals(DATEVALUE("20 Feb 2015"), 42055);
3771+  assertEquals(DATEVALUE("20 Mar 2015"), 42083);
3772+  assertEquals(DATEVALUE("20 Apr 2015"), 42114);
3773+  assertEquals(DATEVALUE("20 May 2015"), 42144);
3774+  assertEquals(DATEVALUE("20 Jun 2015"), 42175);
3775+  assertEquals(DATEVALUE("20 Jul 2015"), 42205);
3776+  assertEquals(DATEVALUE("20 Aug 2015"), 42236);
3777+  assertEquals(DATEVALUE("20 Sep 2015"), 42267);
3778+  assertEquals(DATEVALUE("20 Oct 2015"), 42297);
3779+  assertEquals(DATEVALUE("20 Nov 2015"), 42328);
3780+  assertEquals(DATEVALUE("20 Dec 2015"), 42358);
3781+  assertEquals(DATEVALUE("29 Feb 2004"), 38046); // leap year, 29th ok
3782+  catchAndAssertEquals(function() {
3783+    DATEVALUE("29 Feb 2001");// not leap year, 29th not ok
3784+  }, ERRORS.VALUE_ERROR);
3785+  catchAndAssertEquals(function() {
3786+    DATEVALUE("32 June 2001");// overload numbers not ok
3787+  }, ERRORS.VALUE_ERROR);
3788+  // delimiter tests
3789+  assertEquals(DATEVALUE("Sun, 09, Feb, 2017"), 42775);
3790+  assertEquals(DATEVALUE("Sun, 09/Feb/2017"), 42775);
3791+  assertEquals(DATEVALUE("09/Feb/2017"), 42775);
3792+  assertEquals(DATEVALUE("09-Feb-2017"), 42775);
3793+  assertEquals(DATEVALUE("09.Feb.2017"), 42775);
3794+  assertEquals(DATEVALUE("09 Feb/2017"), 42775);
3795+  assertEquals(DATEVALUE("09 . Feb . 2017"), 42775);
3796+  // If the delimiters don't match the first one should be a space.
3797+  catchAndAssertEquals(function() {
3798+    DATEVALUE("09.Feb/2017");
3799+  }, ERRORS.VALUE_ERROR);
3800+  // Comma delimiters should be followed by spaces.
3801+  catchAndAssertEquals(function() {
3802+    DATEVALUE("09,Feb,2017");
3803+  }, ERRORS.VALUE_ERROR);
3804+  // timestamp tests
3805+  assertEquals(DATEVALUE("24/June/1992 10am"), 33779);
3806+  assertEquals(DATEVALUE("24/June/1992 10:10"), 33779);
3807+  assertEquals(DATEVALUE("24/June/1992 10:10am"), 33779);
3808+  assertEquals(DATEVALUE("24/June/1992 10:10:10"), 33779);
3809+  assertEquals(DATEVALUE("24/June/1992 10:10:10am"), 33779);
3810+  assertEquals(DATEVALUE("24/June/1992  10  am"), 33779);
3811+  assertEquals(DATEVALUE("24/June/1992 10: 10 "), 33779);
3812+  assertEquals(DATEVALUE("24/June/1992 10: 10 pm"), 33779);
3813+  assertEquals(DATEVALUE("24/June/1992 10: 10: 10"), 33779);
3814+  assertEquals(DATEVALUE("24/June/1992  10: 10: 10    am   "), 33779);
3815+  // MONTHNAME_DAY_YEAR, Month(fd)DD(fd)YYYY, 'Aug 19 2020' ============================================================
3816+  assertEquals(DATEVALUE("Sun Feb 09 2017"), 42775);
3817+  assertEquals(DATEVALUE("Sun Feb 9 2017"), 42775);
3818+  assertEquals(DATEVALUE("Mon Feb 09 2017"), 42775);
3819+  assertEquals(DATEVALUE("Thursday Feb 09 2017"), 42775);
3820+  assertEquals(DATEVALUE("Thursday February 09 2017"), 42775);
3821+  assertEquals(DATEVALUE("Sun September 01 20"), 44075);
3822+  assertEquals(DATEVALUE("Sun, Feb, 09, 2017"), 42775);
3823+  assertEquals(DATEVALUE("May 20 1992"), 33744);
3824+  assertEquals(DATEVALUE("December 31 100"), -657070);
3825+  assertEquals(DATEVALUE("January 13 0030"), 10971);
3826+  assertEquals(DATEVALUE("January 13 1200"), -255656);
3827+  assertEquals(DATEVALUE("January 22 2222"), 117631);
3828+  assertEquals(DATEVALUE("November 3 4243"), 856071);
3829+  assertEquals(DATEVALUE("Feb 29 2004"), 38046); // leap year, 29th ok
3830+  catchAndAssertEquals(function() {
3831+    DATEVALUE("Feb 29 2001");// not leap year, 29th not ok
3832+  }, ERRORS.VALUE_ERROR);
3833+  catchAndAssertEquals(function() {
3834+    DATEVALUE("June 32 2001");// overload numbers not ok
3835+  }, ERRORS.VALUE_ERROR);
3836+  // YEAR_MONTHDIG, YYYY(fd)MM, '1992/06' ==============================================================================
3837+  assertEquals(DATEVALUE("2017/01"), 42736);
3838+  assertEquals(DATEVALUE("2017/02"), 42767);
3839+  assertEquals(DATEVALUE("2017/03"), 42795);
3840+  assertEquals(DATEVALUE("2017/04"), 42826);
3841+  assertEquals(DATEVALUE("2017/05"), 42856);
3842+  assertEquals(DATEVALUE("2017/06"), 42887);
3843+  assertEquals(DATEVALUE("2017/07"), 42917);
3844+  assertEquals(DATEVALUE("2017/08"), 42948);
3845+  assertEquals(DATEVALUE("2017/09"), 42979);
3846+  assertEquals(DATEVALUE("2017/10"), 43009);
3847+  assertEquals(DATEVALUE("2017/11"), 43040);
3848+  assertEquals(DATEVALUE("2017/12"), 43070);
3849+  assertEquals(DATEVALUE("2017/01"), 42736);
3850+  // delimiter tests
3851+  assertEquals(DATEVALUE("Thursday 2017/01"), 42736);
3852+  assertEquals(DATEVALUE("Thursday, 2017/01"), 42736);
3853+  assertEquals(DATEVALUE("2017/01"), 42736);
3854+  assertEquals(DATEVALUE("2017-01"), 42736);
3855+  assertEquals(DATEVALUE("2017. 01"), 42736);
3856+  assertEquals(DATEVALUE("2017 01"), 42736);
3857+  assertEquals(DATEVALUE("2017, 01"), 42736);
3858+  // Comma and period delimiters should be followed by spaces.
3859+  catchAndAssertEquals(function() {
3860+    DATEVALUE("2017,01");
3861+  }, ERRORS.VALUE_ERROR);
3862+  catchAndAssertEquals(function() {
3863+    DATEVALUE("2017.01");
3864+  }, ERRORS.VALUE_ERROR);
3865+  // timestamp test
3866+  assertEquals(DATEVALUE("2017-01 10am"), 42736);
3867+  assertEquals(DATEVALUE("2017-01 10:10"), 42736);
3868+  assertEquals(DATEVALUE("2017-01 10:10am"), 42736);
3869+  assertEquals(DATEVALUE("2017-01 10:10:10"), 42736);
3870+  assertEquals(DATEVALUE("2017-01 10:10:10am"), 42736);
3871+  assertEquals(DATEVALUE("2017-01  10  am"), 42736);
3872+  assertEquals(DATEVALUE("2017-01 10: 10 "), 42736);
3873+  assertEquals(DATEVALUE("2017-01 10: 10 pm"), 42736);
3874+  assertEquals(DATEVALUE("2017-01 10: 10: 10"), 42736);
3875+  assertEquals(DATEVALUE("2017-01  10: 10: 10    am   "), 42736);
3876+  // MONTHDIG_YEAR, MM(fd)YYYY, '06/1992' ================================================================================
3877+  assertEquals(DATEVALUE("01/2017"), 42736);
3878+  assertEquals(DATEVALUE("02/2017"), 42767);
3879+  assertEquals(DATEVALUE("03/2017"), 42795);
3880+  assertEquals(DATEVALUE("04/2017"), 42826);
3881+  assertEquals(DATEVALUE("05/2017"), 42856);
3882+  assertEquals(DATEVALUE("06/2017"), 42887);
3883+  assertEquals(DATEVALUE("07/2017"), 42917);
3884+  assertEquals(DATEVALUE("08/2017"), 42948);
3885+  assertEquals(DATEVALUE("09/2017"), 42979);
3886+  assertEquals(DATEVALUE("10/2017"), 43009);
3887+  assertEquals(DATEVALUE("11/2017"), 43040);
3888+  assertEquals(DATEVALUE("12/2017"), 43070);
3889+  // delimiter tests
3890+  assertEquals(DATEVALUE("Thursday 01/2017"), 42736);
3891+  assertEquals(DATEVALUE("Thursday, 01/2017"), 42736);
3892+  assertEquals(DATEVALUE("1/2017"), 42736);
3893+  assertEquals(DATEVALUE("01-2017"), 42736);
3894+  assertEquals(DATEVALUE("01. 2017"), 42736);
3895+  assertEquals(DATEVALUE("01, 2017"), 42736);
3896+  // Comma, period delimiters should be followed by spaces.
3897+  catchAndAssertEquals(function() {
3898+    DATEVALUE("01,2017");
3899+  }, ERRORS.VALUE_ERROR);
3900+  catchAndAssertEquals(function() {
3901+    DATEVALUE("01.2017");
3902+  }, ERRORS.VALUE_ERROR);
3903+  // 0 is not a month
3904+  catchAndAssertEquals(function() {
3905+    DATEVALUE("0/2017");
3906+  }, ERRORS.VALUE_ERROR);
3907+  // timestamp test
3908+  assertEquals(DATEVALUE("01-2017 10am"), 42736);
3909+  assertEquals(DATEVALUE("01-2017 10:10"), 42736);
3910+  assertEquals(DATEVALUE("01-2017 10:10am"), 42736);
3911+  assertEquals(DATEVALUE("01-2017 10:10:10"), 42736);
3912+  assertEquals(DATEVALUE("01-2017 10:10:10am"), 42736);
3913+  assertEquals(DATEVALUE("01-2017  10  am"), 42736);
3914+  assertEquals(DATEVALUE("01-2017 10: 10 "), 42736);
3915+  assertEquals(DATEVALUE("01-2017 10: 10 pm"), 42736);
3916+  assertEquals(DATEVALUE("01-2017 10: 10: 10"), 42736);
3917+  assertEquals(DATEVALUE("01-2017  10: 10: 10    am   "), 42736);
3918+  // YEAR_MONTHNAME, YYYY(fd)Month, '1992/Aug' =========================================================================
3919+  assertEquals(DATEVALUE("2017 January"), 42736);
3920+  assertEquals(DATEVALUE("2017 February"), 42767);
3921+  assertEquals(DATEVALUE("2017 March"), 42795);
3922+  assertEquals(DATEVALUE("2017 April"), 42826);
3923+  assertEquals(DATEVALUE("2017 May"), 42856);
3924+  assertEquals(DATEVALUE("2017 June"), 42887);
3925+  assertEquals(DATEVALUE("2017 July"), 42917);
3926+  assertEquals(DATEVALUE("2017 August"), 42948);
3927+  assertEquals(DATEVALUE("2017 September"), 42979);
3928+  assertEquals(DATEVALUE("2017 October"), 43009);
3929+  assertEquals(DATEVALUE("2017 November"), 43040);
3930+  assertEquals(DATEVALUE("2017 December"), 43070);
3931+  // delimiter tests
3932+  assertEquals(DATEVALUE("Thursday 2017 January"), 42736);
3933+  assertEquals(DATEVALUE("Thursday, 2017 January"), 42736);
3934+  assertEquals(DATEVALUE("2017/January"), 42736);
3935+  assertEquals(DATEVALUE("2017-January"), 42736);
3936+  assertEquals(DATEVALUE("2017. January"), 42736);
3937+  assertEquals(DATEVALUE("2017, January"), 42736);
3938+  // Comma delimiters should be followed by spaces.
3939+  catchAndAssertEquals(function() {
3940+    DATEVALUE("2017,January");
3941+  }, ERRORS.VALUE_ERROR);
3942+  catchAndAssertEquals(function() {
3943+    DATEVALUE("2017.January");
3944+  }, ERRORS.VALUE_ERROR);
3945+  // timestamp test
3946+  assertEquals(DATEVALUE("2017-January 10am"), 42736);
3947+  assertEquals(DATEVALUE("2017-January 10:10"), 42736);
3948+  assertEquals(DATEVALUE("2017-January 10:10am"), 42736);
3949+  assertEquals(DATEVALUE("2017-January 10:10:10"), 42736);
3950+  assertEquals(DATEVALUE("2017-January 10:10:10am"), 42736);
3951+  assertEquals(DATEVALUE("2017-January  10  am"), 42736);
3952+  assertEquals(DATEVALUE("2017-January 10: 10 "), 42736);
3953+  assertEquals(DATEVALUE("2017-January 10: 10 pm"), 42736);
3954+  assertEquals(DATEVALUE("2017-January 10: 10: 10"), 42736);
3955+  assertEquals(DATEVALUE("2017-January  10: 10: 10    am   "), 42736);
3956+  // MONTHNAME_YEAR, Month(fd)YYYY, 'Aug 1992' =========================================================================
3957+  assertEquals(DATEVALUE("January 2017"), 42736);
3958+  assertEquals(DATEVALUE("February 2017"), 42767);
3959+  assertEquals(DATEVALUE("March 2017"), 42795);
3960+  assertEquals(DATEVALUE("April 2017"), 42826);
3961+  assertEquals(DATEVALUE("May 2017"), 42856);
3962+  assertEquals(DATEVALUE("June 2017"), 42887);
3963+  assertEquals(DATEVALUE("July 2017"), 42917);
3964+  assertEquals(DATEVALUE("August 2017"), 42948);
3965+  assertEquals(DATEVALUE("September 2017"), 42979);
3966+  assertEquals(DATEVALUE("October 2017"), 43009);
3967+  assertEquals(DATEVALUE("November 2017"), 43040);
3968+  assertEquals(DATEVALUE("December 2017"), 43070);
3969+  assertEquals(DATEVALUE("  Feb    2017  "), 42767);
3970+  assertEquals(DATEVALUE("Feb-2017"), 42767);
3971+  assertEquals(DATEVALUE("Feb. 2017"), 42767);
3972+  assertEquals(DATEVALUE("Feb/2017"), 42767);
3973+  assertEquals(DATEVALUE("Feb    .    2017"), 42767);
3974+  assertEquals(DATEVALUE("Feb -      2017"), 42767);
3975+  assertEquals(DATEVALUE("January 0030"), 10959);
3976+  assertEquals(DATEVALUE("November 4243"), 856069);
3977+  assertEquals(DATEVALUE("December 0100"), -657100);
3978+  assertEquals(DATEVALUE("Jan 2017"), 42736);
3979+  assertEquals(DATEVALUE("Feb 2017"), 42767);
3980+  assertEquals(DATEVALUE("Mar 2017"), 42795);
3981+  assertEquals(DATEVALUE("Apr 2017"), 42826);
3982+  assertEquals(DATEVALUE("May 2017"), 42856);
3983+  assertEquals(DATEVALUE("Jun 2017"), 42887);
3984+  assertEquals(DATEVALUE("Jul 2017"), 42917);
3985+  assertEquals(DATEVALUE("Aug 2017"), 42948);
3986+  assertEquals(DATEVALUE("Sep 2017"), 42979);
3987+  assertEquals(DATEVALUE("Oct 2017"), 43009);
3988+  assertEquals(DATEVALUE("Nov 201