|
|
|
class DateUtils {
|
|
|
|
//--------------------------
|
|
|
|
// constructor
|
|
|
|
//--------------------------
|
|
|
|
constructor() {}
|
|
|
|
|
|
|
|
//--------------------------
|
|
|
|
// methods
|
|
|
|
//--------------------------
|
|
|
|
getMKtime() {
|
|
|
|
var time =
|
|
|
|
new Date(
|
|
|
|
new Date().getFullYear(),
|
|
|
|
new Date().getMonth(),
|
|
|
|
new Date().getDate(),
|
|
|
|
new Date().getHours(),
|
|
|
|
new Date().getMinutes(),
|
|
|
|
new Date().getSeconds(),
|
|
|
|
0
|
|
|
|
).getTime() / 1000;
|
|
|
|
return time;
|
|
|
|
}
|
|
|
|
|
|
|
|
convertMKtime(seconds) {
|
|
|
|
var date = new Date(seconds * 1000);
|
|
|
|
return date;
|
|
|
|
}
|
|
|
|
|
|
|
|
getDate(type, rawdate) {
|
|
|
|
var day =
|
|
|
|
rawdate != null || rawdate != ''
|
|
|
|
? String(new Date(rawdate).getUTCDate())
|
|
|
|
: String(new Date().getUTCDate());
|
|
|
|
var month =
|
|
|
|
rawdate != null || rawdate != ''
|
|
|
|
? String(new Date(rawdate).getUTCMonth() + 1)
|
|
|
|
: String(new Date().getUTCMonth() + 1);
|
|
|
|
var year =
|
|
|
|
rawdate != null || rawdate != ''
|
|
|
|
? String(new Date(rawdate).getUTCFullYear())
|
|
|
|
: String(new Date().getUTCFullYear());
|
|
|
|
var hour =
|
|
|
|
rawdate != null || rawdate != ''
|
|
|
|
? String(new Date(rawdate).getUTCHours())
|
|
|
|
: String(new Date().getUTCHours());
|
|
|
|
var minute =
|
|
|
|
rawdate != null || rawdate != ''
|
|
|
|
? String(new Date(rawdate).getUTCMinutes())
|
|
|
|
: String(new Date().getUTCMinutes());
|
|
|
|
var seconds =
|
|
|
|
rawdate != null || rawdate != ''
|
|
|
|
? String(new Date(rawdate).getUTCSeconds())
|
|
|
|
: String(new Date().getUTCSeconds());
|
|
|
|
var millisecond =
|
|
|
|
rawdate != null || rawdate != ''
|
|
|
|
? String(new Date(rawdate).getUTCMilliseconds())
|
|
|
|
: String(new Date().getUTCMilliseconds());
|
|
|
|
var offset =
|
|
|
|
rawdate != null || rawdate != ''
|
|
|
|
? String(new Date(rawdate).getTimezoneOffset())
|
|
|
|
: String(new Date().getTimezoneOffset());
|
|
|
|
if (day.length == 1) day = String('0' + day);
|
|
|
|
if (month.length == 1) month = String('0' + month);
|
|
|
|
offset = String(offset / 60);
|
|
|
|
if (offset.length == 1) offset = String('0' + offset);
|
|
|
|
switch (type) {
|
|
|
|
case 'day':
|
|
|
|
return day;
|
|
|
|
|
|
|
|
case 'month':
|
|
|
|
return month;
|
|
|
|
case 'year':
|
|
|
|
return year;
|
|
|
|
case 'stamp':
|
|
|
|
return String(
|
|
|
|
year +
|
|
|
|
'-' +
|
|
|
|
month +
|
|
|
|
'-' +
|
|
|
|
day +
|
|
|
|
' ' +
|
|
|
|
hour +
|
|
|
|
':' +
|
|
|
|
minute +
|
|
|
|
':' +
|
|
|
|
seconds +
|
|
|
|
'.' +
|
|
|
|
millisecond +
|
|
|
|
'-' +
|
|
|
|
offset
|
|
|
|
);
|
|
|
|
default:
|
|
|
|
return String(year + '-' + month + '-' + day);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------
|
|
|
|
// event handlers
|
|
|
|
//--------------------------
|
|
|
|
}
|
|
|
|
|
|
|
|
export default DateUtils;
|