Prevent datepicker from crashing when using date only and the timezone is not UTC
This commit is contained in:
@@ -53,11 +53,7 @@ export class ModuleFieldDateTime extends ModuleField {
|
||||
}
|
||||
|
||||
const o = this.options
|
||||
let m = moment(value)
|
||||
|
||||
if (o.onlyTime) {
|
||||
m = moment(value, ['YYYY-MM-DD HH:mm', 'YYYY-MM-DD', 'HH:mm'])
|
||||
}
|
||||
const m = moment(value, ['YYYY-MM-DDTHH:mm:ssZ', 'YYYY-MM-DD HH:mm', 'YYYY-MM-DD', 'HH:mm'])
|
||||
|
||||
if (o.outputRelative) {
|
||||
return m.fromNow()
|
||||
@@ -66,7 +62,7 @@ export class ModuleFieldDateTime extends ModuleField {
|
||||
} else if (o.onlyTime) {
|
||||
return fmt.time(m)
|
||||
} else if (o.onlyDate) {
|
||||
return fmt.date(m)
|
||||
return fmt.date(moment(value, 'YYYY-MM-DD'))
|
||||
} else {
|
||||
return fmt.fullDateTime(m)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,11 @@ export function getDate (value: string|undefined): string | undefined {
|
||||
return undefined
|
||||
}
|
||||
|
||||
return moment.utc(value).local().format('YYYY-MM-DD')
|
||||
if (moment(value, 'YYYY-MM-DDTHH:mm:ssZ', true).isValid()) {
|
||||
return moment.utc(value).local().format('YYYY-MM-DD')
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
export function getTime (value: string|undefined): string | undefined {
|
||||
|
||||
Reference in New Issue
Block a user