Commit e104ce96 authored by Anton's avatar Anton

Preserve time zone when working with ISO dates and Mongo queries

Closes #106
parent f2d4198d
......@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Fixed
- Perform date related queries to MongoDB with properly formatted timezones (see: [#106](https://gitlab.rlp.net/motionbank/systems-frontend/issues/106))
### Changed
- "More Info" button on welcome page now links to medium article
......
......@@ -150,7 +150,7 @@
const videoAnnotation = result.items.shift()
if (videoAnnotation) {
_this.video = videoAnnotation
_this.videoTime = Date.parse(_this.video.target.selector.value)
_this.videoTime = DateTime.fromISO(_this.video.target.selector.value, { setZone: true })
_this.contextTime = _this.videoTime
const query = {
type: constants.MAP_TYPE_TIMELINE,
......@@ -164,8 +164,8 @@
}
})
const selectorValue = videoAnnotation.target.selector.value
const startDate = Date.parse(selectorValue)
const endDate = DateTime.fromMillis(startDate + (_this.videoMeta.duration * 1000))
const startDate = DateTime.fromISO(selectorValue, { setZone: true })
const endDate = startDate.plus(_this.videoMeta.duration * 1000)
const endDateISO = endDate.toISO()
const annotationsQuery = {
'target.id': videoAnnotation.target.id,
......
......@@ -181,9 +181,8 @@
'body.type': { $in: ['TextualBody', 'VocabularyEntry'] }
}
if (this.metadata.duration) {
query['target.selector.value']['$lte'] = DateTime.fromISO(this.video.target.selector.value)
.plus(this.metadata.duration * 1000)
.toISO()
const start = DateTime.fromISO(this.video.target.selector.value, { setZone: true })
query['target.selector.value']['$lte'] = start.plus(this.metadata.duration * 1000).toISO()
}
const results = await this.$store.dispatch('annotations/find', query)
for (let item of results.items) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment