spreadsheet
typeScript/javascript spreadsheet parser, with formulas.
git clone https://git.vogt.world/spreadsheet.git
Log | Files | README.md
← All files
name: tests/Formulas/DateFormulasTestTimeOverride.ts
-rw-r--r--
1098
 1import {
 2  NOW,
 3  DATEVALUE,
 4  TODAY
 5} from "../../src/Formulas/Date"
 6import * as ERRORS from "../../src/Errors";
 7import {
 8  assertEquals,
 9  catchAndAssertEquals,
10  test,
11  lockDate
12} from "../Utils/Asserts"
13
14test("NOW", function(){
15  lockDate(2012, 11, 10, 4, 55, 4);
16  assertEquals(NOW(), 41253.45490740741);
17  lockDate(1999, 11, 10, 4, 55, 4);
18  assertEquals(NOW(), 36504.45490740741);
19  lockDate(1999, 9, 22, 4, 55, 4);
20  assertEquals(NOW(), 36455.41324074074);
21  lockDate(1944, 1, 2, 1, 11, 55);
22  assertEquals(NOW(), 16104.29994212963);
23  catchAndAssertEquals(function() {
24    NOW.apply(this, [12]);
25  }, ERRORS.NA_ERROR);
26});
27
28
29test("TODAY", function(){
30  lockDate(2012, 11, 10, 4, 55, 4);
31  assertEquals(TODAY(), DATEVALUE("Dec 10 2012"));
32  lockDate(1999, 11, 10, 4, 55, 4);
33  assertEquals(TODAY(), DATEVALUE("Dec 10 1999"));
34  lockDate(1999, 9, 22, 4, 55, 4);
35  assertEquals(TODAY(), DATEVALUE("Oct 22 1999"));
36  lockDate(1944, 1, 2, 1, 11, 55);
37  assertEquals(TODAY(), DATEVALUE("Feb 2 1944"));
38  catchAndAssertEquals(function() {
39    TODAY.apply(this, [12]);
40  }, ERRORS.NA_ERROR);
41});