Skip to content

Commit

Permalink
fix: time interval simple input parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
arildm committed Jul 11, 2024
1 parent c73c6cb commit bc7fe43
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 5 additions & 7 deletions app/scripts/extended.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down

0 comments on commit bc7fe43

Please sign in to comment.