aboutsummaryrefslogtreecommitdiff
path: root/src/Utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/Utils.ts')
-rw-r--r--src/Utils.ts21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/Utils.ts b/src/Utils.ts
index 5f9475f23..a060e4a2c 100644
--- a/src/Utils.ts
+++ b/src/Utils.ts
@@ -895,3 +895,24 @@ export function setupMoveUpEvents(
document.addEventListener('pointerup', _upEvent, true);
document.addEventListener('click', _clickEvent, true);
}
+
+export function dateRangeStrToDates (dateStr: string) {
+ // dateStr in yyyy-mm-dd format
+ const dateRangeParts = dateStr.split("|"); // splits into from and to date
+ const fromParts = dateRangeParts[0].split("-");
+ const toParts = dateRangeParts[1].split("-");
+
+ const fromYear = parseInt(fromParts[0]);
+ const fromMonth = parseInt(fromParts[1])-1;
+ const fromDay = parseInt(fromParts[2]);
+
+ const toYear = parseInt(toParts[0]);
+ const toMonth = parseInt(toParts[1])-1;
+ const toDay = parseInt(toParts[2]);
+
+
+ return [
+ new Date(fromYear, fromMonth, fromDay),
+ new Date(toYear, toMonth, toDay)
+ ];
+} \ No newline at end of file