spreadsheet
typeScript/javascript spreadsheet parser, with formulas.
git clone https://git.vogt.world/spreadsheet.git
Log | Files | README.md
← Commit log
commit
message
Adding moment to project, implementing certain formulas
author
Ben Vogt <[email protected]>
date
2017-01-08 18:22:45
stats
4 file(s) changed, 10 insertions(+), 4 deletions(-)
files
README.md
package.json
src/SupportedFormulas.ts
tests/SheetFormulaTest.ts
 1diff --git a/README.md b/README.md
 2index bf3d582..2f14185 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-* EDATE
10 * EOMONTH
11 * FDIST
12 * FINV
13diff --git a/package.json b/package.json
14index 0ecc326..5fdc4a4 100644
15--- a/package.json
16+++ b/package.json
17@@ -9,6 +9,7 @@
18   "author": "vogtb <bvogt at gmail.com>",
19   "license": "MIT",
20   "dependencies": {
21-    "formulajs": "^1.0.8"
22+    "formulajs": "^1.0.8",
23+    "moment": "^2.17.1"
24   }
25 }
26diff --git a/src/SupportedFormulas.ts b/src/SupportedFormulas.ts
27index 79eff7c..51498e6 100644
28--- a/src/SupportedFormulas.ts
29+++ b/src/SupportedFormulas.ts
30@@ -1,3 +1,6 @@
31+/// <reference path="../node_modules/moment/moment.d.ts"/>
32+import * as moment from "moment";
33+
34 const SUPPORTED_FORMULAS = [
35   'ABS', 'ACCRINT', 'ACOS', 'ACOSH', 'ACOTH', 'AND', 'ARABIC', 'ASIN', 'ASINH', 'ATAN', 'ATAN2', 'ATANH', 'AVEDEV', 'AVERAGE', 'AVERAGEA', 'AVERAGEIF',
36   'BASE', 'BESSELI', 'BESSELJ', 'BESSELK', 'BESSELY', 'BETADIST', 'BETAINV', 'BIN2DEC', 'BIN2HEX', 'BIN2OCT', 'BINOMDIST', 'BINOMDISTRANGE', 'BINOMINV', 'BITAND', 'BITLSHIFT', 'BITOR', 'BITRSHIFT', 'BITXOR',
37@@ -22,6 +25,9 @@ const OverrideFormulas = {
38   },
39   DATEVALUE: function (dateString: string) : Date {
40     return new Date(dateString);
41+  },
42+  EDATE: function (start_date: Date, months) {
43+    return moment(start_date).add(months, 'months').toDate();
44   }
45 };
46 
47diff --git a/tests/SheetFormulaTest.ts b/tests/SheetFormulaTest.ts
48index c58034f..48710ff 100644
49--- a/tests/SheetFormulaTest.ts
50+++ b/tests/SheetFormulaTest.ts
51@@ -289,7 +289,7 @@ testFormula('=DOLLARFR(100.1, 32)', 100.032);
52 testFormula('=AND(10)', true);
53 
54 // Test EDATE
55-// TODO: This should work
56+testFormulaToDate('=EDATE(DATE(1992, 6, 24), 1)', new Date('Fri Jul 24 1992 00:00:00 GMT-0500 (CDT)').getTime());
57 
58 // Test EFFECT
59 testFormula('=EFFECT(0.99, 12)', 1.5890167507927795);