diff options
| author | Furkan Sahin <furkan-dev@proton.me> | 2022-08-07 22:41:12 -0500 |
|---|---|---|
| committer | Furkan Sahin <furkan-dev@proton.me> | 2022-08-07 22:41:12 -0500 |
| commit | e5fbe70e25f5b5c40b335f4385d7351f2e52d944 (patch) | |
| tree | b330dfd341910a622a4ff70525058f0a8f8b96a8 /src | |
| parent | 20e3de81d6feccee156738534d5ac61517832656 (diff) | |
`bugfix` Strawpoll output is parsed correctly now. I included a special case for the troublesome last elements.
Diffstat (limited to 'src')
| -rw-r--r-- | src/util/parser.ts | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/util/parser.ts b/src/util/parser.ts index 2eca9f9..66cb3f8 100644 --- a/src/util/parser.ts +++ b/src/util/parser.ts @@ -285,19 +285,17 @@ function parseStrawpollTimesEntry(pt_slots: string[], time_slots: string[]): Eve let i = 0; for (; i < pt_slots.length; i++) { if (pt_slots[i] == "1") { - const e_i = idk(time_slots[i]); + const e_i = timeslotToEvent(time_slots[i]); while (pt_slots[i + 1] == "1") ++i; - // BUG When the end time is the last timeslot, i is not incremented when it clearly should be. I can see through logging that it safely registers a next element and that the next element is == 1, however the next step of incrementing does not occur. - console.log("End time i+1", pt_slots[i + 1]) - const e_f = idk(time_slots[i]); - console.log("got e_f with, ", time_slots[i]) + // * Hacky bugfix for last timeslot never being used + const e_f = i == pt_slots.length - 2 ? timeslotToEvent(time_slots[i + 1]) : timeslotToEvent(time_slots[i]); res.push(new EventInfo(e_i.days, e_i.start, e_f.end)); } }; return res } -function idk(time_slot: string): EventInfo { +function timeslotToEvent(time_slot: string): EventInfo { const regex = /\(([^)]*)\)/; // find value between parantheses eg ($1) find $1 const match = time_slot.match(regex) const strawpoll_date = time_slot.split(" ")[0] + `T${match[1].split(" ")[0]}`; |
