[UI] null check on datetime* functions.

This commit is contained in:
Fabio Manganiello 2024-11-02 15:48:35 +01:00
parent 13856365fc
commit 6936a67182
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -3,6 +3,8 @@ export default {
name: "DateTime", name: "DateTime",
methods: { methods: {
formatDate(date, year=false) { formatDate(date, year=false) {
if (date == null)
return null
if (typeof date === 'number') if (typeof date === 'number')
date = new Date(date * 1000) date = new Date(date * 1000)
else if (typeof date === 'string') else if (typeof date === 'string')
@ -12,6 +14,8 @@ export default {
}, },
formatTime(date, seconds=true) { formatTime(date, seconds=true) {
if (date == null)
return null
if (typeof date === 'number') if (typeof date === 'number')
date = new Date(date * 1000) date = new Date(date * 1000)
if (typeof date === 'string') if (typeof date === 'string')
@ -21,6 +25,9 @@ export default {
}, },
formatDateTime(date, year=false, seconds=true, skipTimeIfMidnight=false) { formatDateTime(date, year=false, seconds=true, skipTimeIfMidnight=false) {
if (date == null)
return null
const now = new Date() const now = new Date()
if (typeof date === 'number') if (typeof date === 'number')
@ -37,6 +44,9 @@ export default {
}, },
formatDuration(duration, seconds=true) { formatDuration(duration, seconds=true) {
if (duration == null)
return null
if (duration == null) if (duration == null)
return '' return ''