forked from platypush/platypush
[UI] null check on datetime* functions.
This commit is contained in:
parent
13856365fc
commit
6936a67182
1 changed files with 10 additions and 0 deletions
|
@ -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 ''
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue