summaryrefslogtreecommitdiffstats
path: root/src/components/Properties
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2019-03-11 12:17:06 +0100
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2019-03-11 12:43:57 +0100
commit7e4484518f6d6d16688fa62542c418f6d2687afd (patch)
treecf6c6fe2ed046ad29b75f23fcf0a32d82df0b474 /src/components/Properties
parent276cd922f52e66af1788e73459fcfbbbb7fed1d2 (diff)
Try to parse invalid date string on date-time properties
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'src/components/Properties')
-rw-r--r--src/components/Properties/PropertyDateTime.vue17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/components/Properties/PropertyDateTime.vue b/src/components/Properties/PropertyDateTime.vue
index bfabf397..670557dc 100644
--- a/src/components/Properties/PropertyDateTime.vue
+++ b/src/components/Properties/PropertyDateTime.vue
@@ -47,7 +47,7 @@
<action :actions="actions" class="property__actions" />
<!-- Real input where the picker shows -->
- <datetime-picker :value="localValue.toJSDate()" :minute-step="10" :lang="lang"
+ <datetime-picker :value="vcardTimeLocalValue.toJSDate()" :minute-step="10" :lang="lang"
:clearable="false" :first-day-of-week="firstDay" :type="inputType"
:readonly="isReadOnly" :format="dateFormat" class="property__value"
confirm @confirm="updateValue" />
@@ -76,7 +76,7 @@ export default {
props: {
value: {
- type: VCardTime,
+ type: [VCardTime, String],
default: '',
required: true
}
@@ -115,6 +115,15 @@ export default {
let isLast = this.isLastProperty ? 1 : 0
// length is always one & add one space at the end
return hasTitle + 1 + isLast
+ },
+
+ // make sure the property is valid
+ vcardTimeLocalValue() {
+ if (typeof this.localValue === 'string') {
+ // eslint-disable-next-line new-cap
+ return new VCardTime.fromDateAndOrTimeString(this.localValue)
+ }
+ return this.localValue
}
},
@@ -196,7 +205,7 @@ export default {
// this is the only possibility for us to ensure
// no data is lost. e.g. if no second are set
// the second will be null and not 0
- let datetimeData = this.localValue.toJSON()
+ let datetimeData = this.vcardTimeLocalValue.toJSON()
let datetime = ''
// FUN FACT: JS date starts month at zero!
@@ -236,7 +245,7 @@ export default {
return datetimeData.year === null
// replace year and remove double spaces
- ? datetime.replace(moment(this.localValue).year(), '').replace(/\s\s+/g, ' ')
+ ? datetime.replace(moment(this.vcardTimeLocalValue).year(), '').replace(/\s\s+/g, ' ')
: datetime
}
}