commit
message
adding some more tests back in
author
Ben Vogt <[email protected]>
date
2017-04-01 21:19:06
stats
3 file(s) changed,
90 insertions(+),
92 deletions(-)
files
src/RawFormulas/Date.ts
src/RawFormulas/Utils.ts
tests/DateFormulasTest.ts
1diff --git a/src/RawFormulas/Date.ts b/src/RawFormulas/Date.ts
2index b6cd9f2..ec345b1 100644
3--- a/src/RawFormulas/Date.ts
4+++ b/src/RawFormulas/Date.ts
5@@ -188,7 +188,7 @@ var DATEVALUE = function (...values) : number {
6 } else {
7 throw new CellError(VALUE_ERROR, "DATEVALUE parameter '" + dateString + "' cannot be parsed to date/time.");
8 }
9- return momentToMutate.set('hours', 0).set('minutes', 0);
10+ return momentToMutate.set('hours', 0).set('minutes', 0).set('seconds', 0);
11 }
12
13 // Check YEAR_MONTHDIG, YYYY(fd)MM, '1992/06'
14diff --git a/src/RawFormulas/Utils.ts b/src/RawFormulas/Utils.ts
15index b2bfc66..6b3e591 100644
16--- a/src/RawFormulas/Utils.ts
17+++ b/src/RawFormulas/Utils.ts
18@@ -527,7 +527,7 @@ class DateRegExBuilder {
19 }
20
21 TIMESTAMP_UNITS_CAPTURE_GROUP() : DateRegExBuilder {
22- this.regexString += "(\\s*([0-9]+)()()\\s*(am|pm)\\s*$)|(\\s+([0-9]+):\\s*([0-9]+)()()\\s*$)|(\\s+(([0-9]+):\\s*([0-9]+)()\\s*(am|pm))\\s*$)|(\\s+(([0-9]+):\\s*([0-9]+):\\s*([0-9]+)())\\s*$)|(\\s+(([0-9]+):\\s*([0-9]+):\\s*([0-9]+)\\s*(am|pm))\\s*$)";
23+ this.regexString += "(\\s*([0-9]+)()()\\s*(am|pm)\\s*$)|(\\s*([0-9]+):\\s*([0-9]+)()()\\s*$)|(\\s*(([0-9]+):\\s*([0-9]+)()\\s*(am|pm))\\s*$)|(\\s*(([0-9]+):\\s*([0-9]+):\\s*([0-9]+)())\\s*$)|(\\s*(([0-9]+):\\s*([0-9]+):\\s*([0-9]+)\\s*(am|pm))\\s*$)";
24 return this;
25 }
26
27diff --git a/tests/DateFormulasTest.ts b/tests/DateFormulasTest.ts
28index 1a47dfc..acc7346 100644
29--- a/tests/DateFormulasTest.ts
30+++ b/tests/DateFormulasTest.ts
31@@ -163,6 +163,92 @@ assertEquals(DATEVALUE("100/12/31 3:33pm"), -657070);
32 assertEquals(DATEVALUE("122/11/10 3:33pm"), -649086);
33 assertEquals(DATEVALUE("2222/1/22 3:33pm"), 117631);
34 assertEquals(DATEVALUE("222/1/22 3:33pm"), -612854);
35+assertEquals(DATEVALUE("1992/1/13 6:22222222am"), 49048); // overload minutes
36+assertEquals(DATEVALUE("1992/1/13 12:720pm"), 33617); // overload minutes
37+assertEquals(DATEVALUE("1992/1/13 00:720pm"), 33617); // overload minutes
38+assertEquals(DATEVALUE("1992/1/13 12:719pm"), 33616); // overload minutes
39+assertEquals(DATEVALUE("1992/1/13 00:720am"), 33616); // overload minutes
40+assertEquals(DATEVALUE("1992/1/13 00:01pm"), 33616); // overload minutes
41+assertEquals(DATEVALUE("1992/1/13 12:66669pm"), 33662); // overload minutes
42+assertEquals(DATEVALUE("1992/1/13 12:66669am"), 33662); // overload minutes
43+assertEquals(DATEVALUE("1992/1/13 12:66249pm"), 33662); // overload minutes
44+assertEquals(DATEVALUE("1992/1/13 12:66249am"), 33662); // overload minutes
45+assertEquals(DATEVALUE("1992/1/13 12:666669am"), 34078); // overload minutes
46+assertEquals(DATEVALUE("1992/1/13 12:666669pm"), 34079); // overload minutes
47+assertEquals(DATEVALUE("1992/1/13 12:100000000am"), 103060); // overload minutes
48+assertEquals(DATEVALUE("1992/1/13 12:0912347287am"), 667190); // overload minutes
49+assertEquals(DATEVALUE("1992/1/13 12:00000912347287am"), 667190); // overload minutes
50+assertEquals(DATEVALUE("1992/1/13 12:1989198298am"), 1415003); // overload minutes
51+assertEquals(DATEVALUE("1992/6/24 0:0:0"), 33779);
52+assertEquals(DATEVALUE("1992/6/24 0000:0000:0000"), 33779);
53+assertEquals(DATEVALUE("0000/01/13 3:33:999999999"), 48112); // overload seconds
54+assertEquals(DATEVALUE("1992/1/13 6:22222222:0"), 49048); // overload minutes
55+assertEquals(DATEVALUE("1992/1/13 12:912347287:10"), 667191); // overload minutes
56+assertEquals(DATEVALUE("1992/1/13 12:100000000:10"), 103060); // overload minutes
57+assertEquals(DATEVALUE("1992/1/13 23:720:10"), 33617); // overload minutes
58+assertEquals(DATEVALUE("1992/1/13 23:719:60"), 33617); // overload minutes, seconds
59+assertEquals(DATEVALUE("1992/6/24 24:00:00"), 33780); // overload hours
60+assertEquals(DATEVALUE("1999/1/01 200000000:999999999:923231312"), 9074624); // overload hours, minutes, seconds
61+assertEquals(DATEVALUE(" 1992/04/19 12: 33: 11 "), 33713);
62+assertEquals(DATEVALUE("0000/01/13 3:33:33"), 36538);
63+assertEquals(DATEVALUE("4243/11/3 200000000:33:444"), 9189404);
64+assertEquals(DATEVALUE("1999/1/13 10:10:10pm"), 36173);
65+assertEquals(DATEVALUE("1992/6/24 0:0:0pm"), 33779);
66+assertEquals(DATEVALUE("1992/6/24 00:0000:0000pm"), 33779);
67+assertEquals(DATEVALUE("0000/01/13 3:33:999999999pm"), 48112); // overload seconds
68+assertEquals(DATEVALUE("1992/1/13 6:22222222:0pm"), 49048); // overload minutes
69+assertEquals(DATEVALUE("1992/1/13 12:912347287:10pm"), 667191); // overload minutes
70+assertEquals(DATEVALUE("1992/1/13 12:100000000:10pm"), 103060); // overload minutes
71+assertEquals(DATEVALUE("1992/6/24 00:00:00am"), 33779);
72+assertEquals(DATEVALUE("1992/06/24 01:44:00am "), 33779);
73+assertEquals(DATEVALUE("1999/1/01 02:59:00pm"), 36161);
74+assertEquals(DATEVALUE("2222/1/01 03:33:00pm"), 117610);
75+assertEquals(DATEVALUE("1902/9/02 12:33:00pm"), 976);
76+assertEquals(DATEVALUE("1902/9/2 12:33:00pm"), 976);
77+assertEquals(DATEVALUE("4243/11/3 12:33:00pm"), 856071);
78+assertEquals(DATEVALUE(" 1992/04/19 12: 33: 00 pm "), 33713);
79+assertEquals(DATEVALUE("1992/5/20 01:33:44am"), 33744);
80+assertEquals(DATEVALUE("1992/6/21 3:33:44pm"), 33776);
81+assertEquals(DATEVALUE("1992/9/29 3:33:44pm"), 33876);
82+assertEquals(DATEVALUE("1992/1/24 3:33:44pm"), 33627);
83+assertEquals(DATEVALUE("1992/12/21 3:33:44pm"), 33959);
84+assertEquals(DATEVALUE("1992/01/31 3:33:44pm"), 33634);
85+assertEquals(DATEVALUE("1992/1/13 3:33:44pm"), 33616);
86+assertEquals(DATEVALUE("2004/2/29 3:33:44pm"), 38046);
87+assertEquals(DATEVALUE("2004/2/28 3:33:44pm "), 38045);
88+assertEquals(DATEVALUE("1999/1/13 3:33:44pm"), 36173);
89+assertEquals(DATEVALUE("1999/01/13 3:33:44pm"), 36173);
90+assertEquals(DATEVALUE("0999/01/13 3:33:44pm"), -329069);
91+assertEquals(DATEVALUE("1200/01/13 3:33:44pm"), -255656);
92+assertEquals(DATEVALUE("0029/01/13 3:33:44pm"), 47131);
93+assertEquals(DATEVALUE("0030/01/13 3:33:44pm"), 10971);
94+assertEquals(DATEVALUE("0044/01/13 3:33:44pm"), 16084);
95+assertEquals(DATEVALUE("0050/01/13 3:33:44pm"), 18276);
96+assertEquals(DATEVALUE("0097/01/13 00:33:44pm"), 35443);
97+assertEquals(DATEVALUE("0099/01/13 3:33:44pm"), 36173);
98+assertEquals(DATEVALUE("0000/01/13 3:33:44pm"), 36538);
99+assertEquals(DATEVALUE("0101/01/13 3:33:44pm"), -657057);
100+assertEquals(DATEVALUE("0100/01/13 3:33:44pm"), -657422);
101+assertEquals(DATEVALUE("100/12/31 3:33:44pm"), -657070);
102+assertEquals(DATEVALUE("122/11/10 3:33:44pm"), -649086);
103+assertEquals(DATEVALUE("2222/1/22 3:33:44pm"), 117631);
104+assertEquals(DATEVALUE("222/1/22 3:33:44pm"), -612854);
105+assertEquals(DATEVALUE("1992/1/13 6:22222222:44am"), 49048); // overload minutes
106+assertEquals(DATEVALUE("1992/1/13 12:720:00pm"), 33617); // overload minutes
107+assertEquals(DATEVALUE("1992/1/13 00:720:00pm"), 33617); // overload minutes
108+assertEquals(DATEVALUE("1992/1/13 12:719:00pm"), 33616); // overload minutes
109+assertEquals(DATEVALUE("1992/1/13 00:720:00am"), 33616); // overload minutes
110+assertEquals(DATEVALUE("1992/1/13 12:719:60pm"), 33617); // overload minutes
111+assertEquals(DATEVALUE("1992/1/13 00:720:00am"), 33616); // overload minutes
112+assertEquals(DATEVALUE("1992/1/13 00:01:00pm"), 33616); // overload minutes
113+assertEquals(DATEVALUE("1992/1/13 12:66669:00pm"), 33662); // overload minutes
114+assertEquals(DATEVALUE("1992/1/13 12:66669:00am"), 33662); // overload minutes
115+assertEquals(DATEVALUE("1992/1/13 12:66249:00pm"), 33662); // overload minutes
116+assertEquals(DATEVALUE("1992/1/13 12:66249:00am"), 33662); // overload minutes
117+assertEquals(DATEVALUE("1992/1/13 12:666669:00am"), 34078); // overload minutes
118+assertEquals(DATEVALUE("1992/1/13 12:666669:00pm"), 34079); // overload minutes
119+assertEquals(DATEVALUE("1992/1/13 12:100000000:00am"), 103060); // overload minutes
120+assertEquals(DATEVALUE("1992/1/13 12:912347287:00am"), 667190); // overload minutes
121 // YEAR_MONTHDIG_DAY, YYYY(fd)MM(fd)DD =================================================================================
122 assertEquals(DATEVALUE("1992/6/24"), 33779);
123 assertEquals(DATEVALUE("1992/06/24"), 33779);
124@@ -529,95 +615,9 @@ assertEquals(DATEVALUE("January-2017 10: 10: 10 am "), 42736);
125
126
127
128-// assertEquals(DATEVALUE("1992/1/13 6:22222222am"), 49048); // overload minutes
129-// assertEquals(DATEVALUE("1992/1/13 12:720pm"), 33617); // overload minutes
130-// assertEquals(DATEVALUE("1992/1/13 00:720pm"), 33617); // overload minutes
131-// assertEquals(DATEVALUE("1992/1/13 12:719pm"), 33616); // overload minutes
132-// assertEquals(DATEVALUE("1992/1/13 00:720am"), 33616); // overload minutes
133-// assertEquals(DATEVALUE("1992/1/13 00:01pm"), 33616); // overload minutes
134-// assertEquals(DATEVALUE("1992/1/13 12:66669pm"), 33662); // overload minutes
135-// assertEquals(DATEVALUE("1992/1/13 12:66669am"), 33662); // overload minutes
136-// assertEquals(DATEVALUE("1992/1/13 12:66249pm"), 33662); // overload minutes
137-// assertEquals(DATEVALUE("1992/1/13 12:66249am"), 33662); // overload minutes
138-// assertEquals(DATEVALUE("1992/1/13 12:666669am"), 34078); // overload minutes
139-// assertEquals(DATEVALUE("1992/1/13 12:666669pm"), 34079); // overload minutes
140-// assertEquals(DATEVALUE("1992/1/13 12:100000000am"), 103060); // overload minutes
141-// assertEquals(DATEVALUE("1992/1/13 12:0912347287am"), 667190); // overload minutes
142-// assertEquals(DATEVALUE("1992/1/13 12:00000912347287am"), 667190); // overload minutes
143-// assertEquals(DATEVALUE("1992/1/13 12:1989198298am"), 1415003); // overload minutes
144-// // YYYY/MM/DD HH:mm:ss
145-// assertEquals(DATEVALUE("1992/6/24 0:0:0"), 33779);
146-// assertEquals(DATEVALUE("1992/6/24 0000:0000:0000"), 33779);
147-// assertEquals(DATEVALUE("0000/01/13 3:33:999999999"), 48112); // overload seconds
148-// assertEquals(DATEVALUE("1992/1/13 6:22222222:0"), 49048); // overload minutes
149-// assertEquals(DATEVALUE("1992/1/13 12:912347287:10"), 667191); // overload minutes
150-// assertEquals(DATEVALUE("1992/1/13 12:100000000:10"), 103060); // overload minutes
151-// assertEquals(DATEVALUE("1992/1/13 23:720:10"), 33617); // overload minutes
152-// assertEquals(DATEVALUE("1992/1/13 23:719:60"), 33617); // overload minutes, seconds
153-// assertEquals(DATEVALUE("1992/6/24 24:00:00"), 33780); // overload hours
154-// assertEquals(DATEVALUE("1999/1/01 200000000:999999999:923231312"), 9074624); // overload hours, minutes, seconds
155-// assertEquals(DATEVALUE(" 1992/04/19 12: 33: 11 "), 33713);
156-// assertEquals(DATEVALUE("0000/01/13 3:33:33"), 36538);
157-// assertEquals(DATEVALUE("4243/11/3 200000000:33:444"), 9189404);
158-// // YYYY/MM/DD HH:mm:ss(am|pm)
159-// assertEquals(DATEVALUE("1999/1/13 10:10:10pm"), 36173);
160-// assertEquals(DATEVALUE("1992/6/24 0:0:0pm"), 33779);
161-// assertEquals(DATEVALUE("1992/6/24 00:0000:0000pm"), 33779);
162-// assertEquals(DATEVALUE("0000/01/13 3:33:999999999pm"), 48112); // overload seconds
163-// assertEquals(DATEVALUE("1992/1/13 6:22222222:0pm"), 49048); // overload minutes
164-// assertEquals(DATEVALUE("1992/1/13 12:912347287:10pm"), 667191); // overload minutes
165-// assertEquals(DATEVALUE("1992/1/13 12:100000000:10pm"), 103060); // overload minutes
166-// assertEquals(DATEVALUE("1992/6/24 00:00:00am"), 33779);
167-// assertEquals(DATEVALUE("1992/06/24 01:44:00am "), 33779);
168-// assertEquals(DATEVALUE("1999/1/01 02:59:00pm"), 36161);
169-// assertEquals(DATEVALUE("2222/1/01 03:33:00pm"), 117610);
170-// assertEquals(DATEVALUE("1902/9/02 12:33:00pm"), 976);
171-// assertEquals(DATEVALUE("1902/9/2 12:33:00pm"), 976);
172-// assertEquals(DATEVALUE("4243/11/3 12:33:00pm"), 856071);
173-// assertEquals(DATEVALUE(" 1992/04/19 12: 33: 00 pm "), 33713);
174-// assertEquals(DATEVALUE("1992/5/20 01:33:44am"), 33744);
175-// assertEquals(DATEVALUE("1992/6/21 3:33:44pm"), 33776);
176-// assertEquals(DATEVALUE("1992/9/29 3:33:44pm"), 33876);
177-// assertEquals(DATEVALUE("1992/1/24 3:33:44pm"), 33627);
178-// assertEquals(DATEVALUE("1992/12/21 3:33:44pm"), 33959);
179-// assertEquals(DATEVALUE("1992/01/31 3:33:44pm"), 33634);
180-// assertEquals(DATEVALUE("1992/1/13 3:33:44pm"), 33616);
181-// assertEquals(DATEVALUE("2004/2/29 3:33:44pm"), 38046);
182-// assertEquals(DATEVALUE("2004/2/28 3:33:44pm "), 38045);
183-// assertEquals(DATEVALUE("1999/1/13 3:33:44pm"), 36173);
184-// assertEquals(DATEVALUE("1999/01/13 3:33:44pm"), 36173);
185-// assertEquals(DATEVALUE("0999/01/13 3:33:44pm"), -329069);
186-// assertEquals(DATEVALUE("1200/01/13 3:33:44pm"), -255656);
187-// assertEquals(DATEVALUE("0029/01/13 3:33:44pm"), 47131);
188-// assertEquals(DATEVALUE("0030/01/13 3:33:44pm"), 10971);
189-// assertEquals(DATEVALUE("0044/01/13 3:33:44pm"), 16084);
190-// assertEquals(DATEVALUE("0050/01/13 3:33:44pm"), 18276);
191-// assertEquals(DATEVALUE("0097/01/13 00:33:44pm"), 35443);
192-// assertEquals(DATEVALUE("0099/01/13 3:33:44pm"), 36173);
193-// assertEquals(DATEVALUE("0000/01/13 3:33:44pm"), 36538);
194-// assertEquals(DATEVALUE("0101/01/13 3:33:44pm"), -657057);
195-// assertEquals(DATEVALUE("0100/01/13 3:33:44pm"), -657422);
196-// assertEquals(DATEVALUE("100/12/31 3:33:44pm"), -657070);
197-// assertEquals(DATEVALUE("122/11/10 3:33:44pm"), -649086);
198-// assertEquals(DATEVALUE("2222/1/22 3:33:44pm"), 117631);
199-// assertEquals(DATEVALUE("222/1/22 3:33:44pm"), -612854);
200-// assertEquals(DATEVALUE("1992/1/13 6:22222222:44am"), 49048); // overload minutes
201-// assertEquals(DATEVALUE("1992/1/13 12:720:00pm"), 33617); // overload minutes
202-// assertEquals(DATEVALUE("1992/1/13 00:720:00pm"), 33617); // overload minutes
203-// assertEquals(DATEVALUE("1992/1/13 12:719:00pm"), 33616); // overload minutes
204-// assertEquals(DATEVALUE("1992/1/13 00:720:00am"), 33616); // overload minutes
205-// assertEquals(DATEVALUE("1992/1/13 12:719:60pm"), 33617); // overload minutes
206-// assertEquals(DATEVALUE("1992/1/13 00:720:00am"), 33616); // overload minutes
207-// assertEquals(DATEVALUE("1992/1/13 00:01:00pm"), 33616); // overload minutes
208-// assertEquals(DATEVALUE("1992/1/13 12:66669:00pm"), 33662); // overload minutes
209-// assertEquals(DATEVALUE("1992/1/13 12:66669:00am"), 33662); // overload minutes
210-// assertEquals(DATEVALUE("1992/1/13 12:66249:00pm"), 33662); // overload minutes
211-// assertEquals(DATEVALUE("1992/1/13 12:66249:00am"), 33662); // overload minutes
212-// assertEquals(DATEVALUE("1992/1/13 12:666669:00am"), 34078); // overload minutes
213-// assertEquals(DATEVALUE("1992/1/13 12:666669:00pm"), 34079); // overload minutes
214-// assertEquals(DATEVALUE("1992/1/13 12:100000000:00am"), 103060); // overload minutes
215-// assertEquals(DATEVALUE("1992/1/13 12:912347287:00am"), 667190); // overload minutes
216-// // (Dayname) Month DD YYYY
217+
218+
219+
220 // assertEquals(DATEVALUE("Sun Feb 09 2017"), 42775);
221 // assertEquals(DATEVALUE("Sun Feb 9 2017"), 42775);
222 // assertEquals(DATEVALUE("Mon Feb 09 2017"), 42775);
223@@ -646,7 +646,8 @@ assertEquals(DATEVALUE("January-2017 10: 10: 10 am "), 42736);
224 // catchAndAssertEquals(function() {
225 // DATEVALUE("32 June 2001");// overload numbers not ok
226 // }, ERRORS.VALUE_ERROR);
227-// // Month YYYY
228+
229+
230 // assertEquals(DATEVALUE("Jan 2017"), 42736);
231 // assertEquals(DATEVALUE("Feb 2017"), 42767);
232 // assertEquals(DATEVALUE("Mar 2017"), 42795);