spreadsheet
typeScript/javascript spreadsheet parser, with formulas.
git clone https://git.vogt.world/spreadsheet.git
Log | Files | README.md
← Commit log
commit
message
Adding formula and test EOMONTH
author
Ben Vogt <[email protected]>
date
2017-01-08 18:37:35
stats
3 file(s) changed, 5 insertions(+), 2 deletions(-)
files
README.md
src/SupportedFormulas.ts
tests/SheetFormulaTest.ts
 1diff --git a/README.md b/README.md
 2index 2f14185..80237e7 100644
 3--- a/README.md
 4+++ b/README.md
 5@@ -9,7 +9,6 @@ Things I should do.
 6 * Include fail state values for all formulas
 7 
 8 ### Write formulas for missing ones
 9-* EOMONTH
10 * FDIST
11 * FINV
12 * SIN
13diff --git a/src/SupportedFormulas.ts b/src/SupportedFormulas.ts
14index 51498e6..b781638 100644
15--- a/src/SupportedFormulas.ts
16+++ b/src/SupportedFormulas.ts
17@@ -28,6 +28,10 @@ const OverrideFormulas = {
18   },
19   EDATE: function (start_date: Date, months) {
20     return moment(start_date).add(months, 'months').toDate();
21+  },
22+  EOMONTH: function (start_date, months) {
23+    var edate = moment(start_date).add(months, 'months');
24+    return new Date(edate.year(), edate.month(), edate.daysInMonth());
25   }
26 };
27 
28diff --git a/tests/SheetFormulaTest.ts b/tests/SheetFormulaTest.ts
29index 48710ff..0c4820b 100644
30--- a/tests/SheetFormulaTest.ts
31+++ b/tests/SheetFormulaTest.ts
32@@ -295,7 +295,7 @@ testFormulaToDate('=EDATE(DATE(1992, 6, 24), 1)', new Date('Fri Jul 24 1992 00:0
33 testFormula('=EFFECT(0.99, 12)', 1.5890167507927795);
34 
35 // EOMONTH
36-// TODO: This should work
37+testFormulaToDate('=EOMONTH(DATE(1992, 6, 24), 1)', new Date('7/31/1992').getTime());
38 
39 // Test ERF
40 testFormula('=ERF(2)', 0.9953222650189527);