spreadsheet
typeScript/javascript spreadsheet parser, with formulas.
git clone https://git.vogt.world/spreadsheet.git
Log | Files | README.md
← Commit log
commit
message
Preparing to use the best of all worlds in the DateRegExBuilder
author
Ben Vogt <[email protected]>
date
2017-03-27 02:21:11
stats
2 file(s) changed, 136 insertions(+), 58 deletions(-)
files
README.md
src/RawFormulas/Date.ts
  1diff --git a/README.md b/README.md
  2index 1e2d4cc..14220cb 100644
  3--- a/README.md
  4+++ b/README.md
  5@@ -83,17 +83,120 @@ MM, YYYY         MONTHDIG_YEAR_COMMA_DELIMIT             months, years
  6 ```
  7 
  8 ### Different Time Formats
  9+```
 10 FORMAT           CONST NAME
 11 HHam             HOUR_MERIDIEM
 12 HH:MM            OVERFLOW_HOURS_OVERFLOW_MINUTES
 13 HH:MMam          HOURS_OVERFLOW_MINUTES_MERIDIEM
 14 HH:MM:SS         OVERFLOW_HOURS_OVERFLOW_MINUTES_SECONDS
 15 HH:MM:SSam       HOURS_MINUTES_SECONDS_OVERFLOW_MERIDIEM
 16+```
 17+
 18+### Condensed Date Formats
 19+```
 20+NOTES
 21+fd = flex_delimitor
 22+all can be prefixed with day name (no op)
 23+all can be suffixed with time (yes op)
 24+
 25+YYYY(fd)MM(fd)DD        YEAR_MONTHDIG_DAY
 26+MM(fd)DD(fd)YYYY        MONTHDIG_DAY_YEAR
 27+Month(fd)DD(fd)YYYY     MONTHNAME_DAY_YEAR
 28+DD(fd)Month(fd)YYYY     DAY_MONTHNAME_YEAR
 29+YYYY(fd)MM              YEAR_MONTHDIG
 30+MM(fd)YYYY              MONTHDIG_YEAR
 31+YYYY(fd)Month           YEAR_MONTHNAME
 32+Month(fd)YYYY           MONTHNAME_YEAR
 33+```
 34+Capture the flex delimiter and invalidate if the three don't match.
 35+
 36+
 37+### List of possible dates that we should be able to parse
 38+* "1999/1/13"                    DONE
 39+ * "1999-1-13"
 40+ * "1999 1 13"
 41+ * "1999.1.13"
 42+ * "1999, 1, 13"
 43+ * "1/13/1999"                    DONE
 44+ * "1-13-1999"
 45+ * "1 13 1999"
 46+ * "1.13.1999"
 47+ * "1, 13, 1999"
 48+ * "1999/1/13 10am"               DONE
 49+ * "1999-1-13 10am"
 50+ * "1999 1 13 10am"
 51+ * "1999.1.13 10am"
 52+ * "1999/1/13 10:22"              DONE
 53+ * "1999-1-13 10:22"
 54+ * "1999 1 13 10:22"
 55+ * "1999.1.13 10:22"
 56+ * "1999/1/13 10:10am"            DONE
 57+ * "1999-1-13 10:10am"
 58+ * "1999 1 13 10:10am"
 59+ * "1999.1.13 10:10am"
 60+ * "1999/1/13 10:10:10"           DONE
 61+ * "1999-1-13 10:10:10"
 62+ * "1999 1 13 10:10:10"
 63+ * "1999.1.13 10:10:10"
 64+ * "1999/1/13 10:10:10pm"         DONE
 65+ * "1999-1-13 10:10:10pm"
 66+ * "1999 1 13 10:10:10pm"
 67+ * "1999.1.13 10:10:10pm"
 68+ * "Sun Feb 09 2017"              DONE
 69+ * "Sun Feb 09 2017 10am"
 70+ * "Sun Feb 09 2017 10:10"
 71+ * "Sun Feb 09 2017 10:10am"
 72+ * "Sun Feb 09 2017 10:10:10"
 73+ * "Sun Feb 09 2017 10:10:10pm"
 74+ * "Sun 09 Feb 2017"              DONE
 75+ * "Sun 09 Feb 2017 10am"
 76+ * "Sun 09 Feb 2017 10:10"
 77+ * "Sun 09 Feb 2017 10:10am"
 78+ * "Sun 09 Feb 2017 10:10:10"
 79+ * "Sun 09 Feb 2017 10:10:10pm"
 80+ * "Feb-2017"                     DONE
 81+ * "Feb-2017 10am"
 82+ * "Feb-2017 10:10"
 83+ * "Feb-2017 10:10am"
 84+ * "Feb-2017 10:10:10"
 85+ * "Feb-2017 10:10:10pm"
 86+ * "Feb 22"                       DONE
 87+ * "Feb 22 10am"
 88+ * "Feb 22 10:10"
 89+ * "Feb 22 10:10am"
 90+ * "Feb 22 10:10:10"
 91+ * "Feb 22 10:10:10pm"
 92+ * "22-Feb"                       DONE
 93+ * "22-Feb 10am"
 94+ * "22-Feb 10:10"
 95+ * "22-Feb 10:10am"
 96+ * "22-Feb 10:10:10"
 97+ * "22-Feb 10:10:10pm"
 98+ * "22-Feb-2017"
 99+ * "22-Feb-2017 10am"
100+ * "22-Feb-2017 10:10"
101+ * "22-Feb-2017 10:10am"
102+ * "22-Feb-2017 10:10:10"
103+ * "22-Feb-2017 10:10:10pm"
104+ * "10-22"
105+ * "10-22 10am"
106+ * "10-22 10:10"
107+ * "10-22 10:10am"
108+ * "10-22 10:10:10"
109+ * "10-22 10:10:10pm"
110+ * "10/2022"
111+ * "10-2022 10am"
112+ * "10-2022 10:10"
113+ * "10-2022 10:10am"
114+ * "10-2022 10:10:10"
115+ * "10-2022 10:10:10pm"
116+
117 
118 * Combine the different time formats into a single regular expression.
119 Throw errors based on whether some units have overflowed. For example 29:99 is ok, but 29:99pm is not ok. This way
120 we're only doubling the number of date-format regular expressions we have to generate. For example, we check
121 YEAR_MONTHDIG_DAY_SLASH_DELIMIT once, and then YEAR_MONTHDIG_DAY_SLASH_DELIMIT_WITH_TIME once.
122+Use something like this: https://regex101.com/r/ZMu74e/2
123 
124 * Dates have special types
125 Like dollars, dates are special types, but can be compared as if they're primatives. For example, this statement is
126diff --git a/src/RawFormulas/Date.ts b/src/RawFormulas/Date.ts
127index 3ee3667..0d0418f 100644
128--- a/src/RawFormulas/Date.ts
129+++ b/src/RawFormulas/Date.ts
130@@ -43,89 +43,39 @@ var DATE = function (...values) {
131 };
132 
133 
134+// const YEAR_MONTHDIG_DAY_SLASH_DELIMIT;
135+// const YEAR_MONTHDIG_DAY_HYPHEN_DELIMIT;
136+// const YEAR_MONTHDIG_DAY_DOT_DELIMIT;
137+// const YEAR_MONTHDIG_DAY_SPACE_DELIMIT;
138+// const YEAR_MONTHDIG_DAY_COMMA_DELIMIT;
139+// const MONTHDIG_DAY_YEAR_SLASH_DELIMIT;
140+// const MONTHDIG_DAY_YEAR_HYPHEN_DELIMIT;
141+// const MONTHDIG_DAY_YEAR_DOT_DELIMIT;
142+// const MONTHDIG_DAY_YEAR_SPACE_DELIMIT;
143+// const MONTHDIG_DAY_YEAR_COMMA_DELIMIT;
144+// const MONTHNAME_DAY_YEAR_COMMON_DELIMITERS;
145+// const DAY_MONTHNAME_YEAR_COMMON_DELIMITERS;
146+// const MONTHNAME_DAY_COMMON_DELIMITERS;
147+// const DAY_MONTHNAME_COMMON_DELIMITERS;
148+// const MONTHNAME_YEAR_COMMON_DELIMITERS;
149+// const YEAR_MONTHNAME_COMMON_DELIMITERS;
150+// const MONTHDIG_DAY_SLASH_DELIMIT;
151+// const MONTHDIG_DAY_HYPHEN_DELIMIT;
152+// const MONTHDIG_DAY_SPACE_DELIMIT;
153+// const MONTHDIG_DAY_DOT_DELIMIT;
154+// const MONTHDIG_DAY_COMMA_DELIMIT;
155+// const MONTHDIG_YEAR_SLASH_DELIMIT;
156+// const MONTHDIG_YEAR_HYPHEN_DELIMIT;
157+// const MONTHDIG_YEAR_SPACE_DELIMIT;
158+// const MONTHDIG_YEAR_DOT_DELIMIT;
159+// const MONTHDIG_YEAR_COMMA_DELIMIT;
160+
161+
162 /**
163  * Converts a provided date string in a known format to a date value.
164  * @param values[0] date_string - The string representing the date. Understood formats include any date format which is
165  * normally auto-converted when entered, without quotation marks, directly into a cell. Understood formats may depend on
166- * region and language settings. Examples include:
167- * "1999/1/13"                    DONE
168- * "1999-1-13"
169- * "1999 1 13"
170- * "1999.1.13"
171- * "1999, 1, 13"
172- * "1/13/1999"                    DONE
173- * "1-13-1999"
174- * "1 13 1999"
175- * "1.13.1999"
176- * "1, 13, 1999"
177- * "1999/1/13 10am"               DONE
178- * "1999-1-13 10am"
179- * "1999 1 13 10am"
180- * "1999.1.13 10am"
181- * "1999/1/13 10:22"              DONE
182- * "1999-1-13 10:22"
183- * "1999 1 13 10:22"
184- * "1999.1.13 10:22"
185- * "1999/1/13 10:10am"            DONE
186- * "1999-1-13 10:10am"
187- * "1999 1 13 10:10am"
188- * "1999.1.13 10:10am"
189- * "1999/1/13 10:10:10"           DONE
190- * "1999-1-13 10:10:10"
191- * "1999 1 13 10:10:10"
192- * "1999.1.13 10:10:10"
193- * "1999/1/13 10:10:10pm"         DONE
194- * "1999-1-13 10:10:10pm"
195- * "1999 1 13 10:10:10pm"
196- * "1999.1.13 10:10:10pm"
197- * "Sun Feb 09 2017"              DONE
198- * "Sun Feb 09 2017 10am"
199- * "Sun Feb 09 2017 10:10"
200- * "Sun Feb 09 2017 10:10am"
201- * "Sun Feb 09 2017 10:10:10"
202- * "Sun Feb 09 2017 10:10:10pm"
203- * "Sun 09 Feb 2017"              DONE
204- * "Sun 09 Feb 2017 10am"
205- * "Sun 09 Feb 2017 10:10"
206- * "Sun 09 Feb 2017 10:10am"
207- * "Sun 09 Feb 2017 10:10:10"
208- * "Sun 09 Feb 2017 10:10:10pm"
209- * "Feb-2017"                     DONE
210- * "Feb-2017 10am"
211- * "Feb-2017 10:10"
212- * "Feb-2017 10:10am"
213- * "Feb-2017 10:10:10"
214- * "Feb-2017 10:10:10pm"
215- * "Feb 22"                       DONE
216- * "Feb 22 10am"
217- * "Feb 22 10:10"
218- * "Feb 22 10:10am"
219- * "Feb 22 10:10:10"
220- * "Feb 22 10:10:10pm"
221- * "22-Feb"                       DONE
222- * "22-Feb 10am"
223- * "22-Feb 10:10"
224- * "22-Feb 10:10am"
225- * "22-Feb 10:10:10"
226- * "22-Feb 10:10:10pm"
227- * "22-Feb-2017"
228- * "22-Feb-2017 10am"
229- * "22-Feb-2017 10:10"
230- * "22-Feb-2017 10:10am"
231- * "22-Feb-2017 10:10:10"
232- * "22-Feb-2017 10:10:10pm"
233- * "10-22"
234- * "10-22 10am"
235- * "10-22 10:10"
236- * "10-22 10:10am"
237- * "10-22 10:10:10"
238- * "10-22 10:10:10pm"
239- * "10/2022"
240- * "10-2022 10am"
241- * "10-2022 10:10"
242- * "10-2022 10:10am"
243- * "10-2022 10:10:10"
244- * "10-2022 10:10:10pm"
245+ * region and language settings.
246  * @returns {number} of days since 1900/1/1, inclusively.
247  * @constructor
248  */