From bc7fe43d809ea330eb527940071673527e04d0f3 Mon Sep 17 00:00:00 2001 From: Arild Matsson Date: Thu, 11 Jul 2024 08:35:49 +0200 Subject: [PATCH] fix: time interval simple input parsing --- CHANGELOG.md | 1 + app/scripts/extended.js | 12 +++++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d62b75e2b..d08c74823 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ - News were sometimes not shown immediately after fetch - In Extended search, the time interval component was ignoring the simple input fields [#377](https://github.com/spraakbanken/korp-frontend/issues/377) + - Also fixed the parsing of the simple input, which was incomplete since way back ## [9.6.0] - 2024-05-27 diff --git a/app/scripts/extended.js b/app/scripts/extended.js index 95512bc27..37029c826 100644 --- a/app/scripts/extended.js +++ b/app/scripts/extended.js @@ -313,15 +313,13 @@ export default _.merge( } s.commitDateInput = () => { if (s.fromDateString) { - let simpleFrom = s.fromDateString.length == 4 - s.fromDate = moment(s.fromDateString, simpleFrom ? "YYYY" : "YYYY-MM-DD").toDate() + const dateString = s.fromDateString.length == 4 ? `${s.fromDateString}-01-01` : s.fromDateString + s.fromDate = moment(dateString).toDate() + s.fromTime = moment("000000", "HHmmss").toDate() } if (s.toDateString) { - let simpleTo = s.toDateString.length == 4 - if (simpleTo) { - var dateString = `${s.toDateString}-12-31` - } - s.toDate = moment(dateString || s.dateString).toDate() + const dateString = s.toDateString.length == 4 ? `${s.toDateString}-12-31` : s.toDateString + s.toDate = moment(dateString).toDate() s.toTime = moment("235959", "HHmmss").toDate() } }