commit
message
Getting started on parsing dates
author
Ben Vogt <[email protected]>
date
2017-01-07 23:22:30
stats
2 file(s) changed,
13 insertions(+),
3 deletions(-)
files
README.md
tests/SheetFormulaTest.ts
1diff --git a/README.md b/README.md
2index 584aca0..8e454c3 100644
3--- a/README.md
4+++ b/README.md
5@@ -7,4 +7,7 @@ Things I should do.
6 ### Write tests for supported formulas.
7
8 ### Parsing interesting values
9-* Expand tests greatly.
10\ No newline at end of file
11+* Expand tests greatly.
12+
13+### Parsing dates
14+* Use moment as storage for dates.
15diff --git a/tests/SheetFormulaTest.ts b/tests/SheetFormulaTest.ts
16index bb3ddb1..63ff140 100644
17--- a/tests/SheetFormulaTest.ts
18+++ b/tests/SheetFormulaTest.ts
19@@ -9,6 +9,14 @@ function testFormula(formula: string, expectation: any) {
20 assertEquals(expectation, cell.getValue());
21 }
22
23+function testFormulaDate(formula: string, expectation: any) {
24+ var sheet = new Sheet();
25+ sheet.setCell("A1", formula);
26+ var cell = sheet.getCell("A1");
27+ assertEquals(null, cell.getError());
28+ assertEquals(expectation, cell.getValue().getTime());
29+}
30+
31 function testFormulaToArray(formula: string, expectation: any) {
32 var sheet = new Sheet();
33 sheet.setCell("A1", formula);
34@@ -230,8 +238,7 @@ testFormula("=CUMIPMT(0.12, 12, 100, 1, 5, 0)", -54.39423242396348);
35 testFormula("=CUMPRINC(0.12, 12, 100, 1, 5, 0)", -26.324171373034403);
36
37 // Test DATE
38-// TODO: DATE should parse dates correctly. Is this a display issue or a parsing issue?
39-// testFormula("=DATE(1992, 6, 24)", "6/24/1992");
40+testFormulaDate("=DATE(1992, 6, 24)", new Date("6/24/1992").getTime());
41
42 // Test DATEVALUE
43 // TODO: DATEVALUE should work.