You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
875 B
35 lines
875 B
3 months ago
|
function getTime(/** timestamp=0 **/) {
|
||
|
var ts = arguments[0] || 0;
|
||
|
var t = ts ? new Date(ts * 1000) : new Date();
|
||
|
return dateTimeFormat(t);
|
||
|
}
|
||
|
|
||
|
function dateTimeFormat(date) {
|
||
|
var y = date.getFullYear();
|
||
|
var m = date.getMonth() + 1;
|
||
|
var d = date.getDate();
|
||
|
var h = date.getHours();
|
||
|
var mi = date.getMinutes();
|
||
|
var s = date.getSeconds();
|
||
|
return [y, m, d].map(formatNumber).join('-') + ' ' + [h, mi, s].map(formatNumber).join(':');
|
||
|
}
|
||
|
|
||
|
function formatNumber(n) {
|
||
|
n = n.toString();
|
||
|
return n[1] ? n : '0' + n
|
||
|
}
|
||
|
|
||
|
function formatDate(date) {
|
||
|
if (isUnde(date)) return ''
|
||
|
return getTime(unixtime(date))
|
||
|
}
|
||
|
|
||
|
function unixtime(date) {
|
||
|
if (isUnde(date)) return undefined;
|
||
|
var pa = /.*\((.*)\)/;
|
||
|
return date.match(pa)[1].substring(0, 10);
|
||
|
}
|
||
|
|
||
|
function isUnde(v) {
|
||
|
return v === '' || v === undefined || v === null;
|
||
|
}
|