|
|
@@ -69,29 +69,28 @@ export function filterObj(obj) {
|
|
|
}
|
|
|
|
|
|
export function dk_formatDate(value, fmt, status) {
|
|
|
- if (value) {
|
|
|
- const _date = value.replace ? new Date(value.replace(/-/g, "/")) : new Date(value);
|
|
|
- if (_date) {
|
|
|
|
|
|
- const Y = _date.getFullYear();
|
|
|
- const M = _date.getMonth() + 1;
|
|
|
- const D = _date.getDate();
|
|
|
- const H = _date.getHours();
|
|
|
- const m = _date.getMinutes();
|
|
|
- const s = _date.getSeconds();
|
|
|
- if (fmt === '年') {
|
|
|
- if (status) {
|
|
|
- return formt(Y) + '年' + formt(M) + '月' + formt(D) + '日' + ' ' + [H, m, s].map(formt).join(':')
|
|
|
- }
|
|
|
- return formt(Y) + '年' + formt(M) + '月' + formt(D) + '日'
|
|
|
- } else {
|
|
|
- if (status) {
|
|
|
- return [Y, M, D].map(formt).join(fmt) + ' ' + [H, m, s].map(formt).join(':')
|
|
|
- }
|
|
|
- return [Y, M, D].map(formt).join(fmt);
|
|
|
- }
|
|
|
+ const _date = value.replace ? new Date(value.replace(/-/g, "/")) : new Date(value);
|
|
|
+ if (_date && _date instanceof Date && !isNaN(_date.getTime())) {
|
|
|
|
|
|
+ const Y = _date.getFullYear();
|
|
|
+ const M = _date.getMonth() + 1;
|
|
|
+ const D = _date.getDate();
|
|
|
+ const H = _date.getHours();
|
|
|
+ const m = _date.getMinutes();
|
|
|
+ const s = _date.getSeconds();
|
|
|
+ if (fmt === '年') {
|
|
|
+ if (status) {
|
|
|
+ return formt(Y) + '年' + formt(M) + '月' + formt(D) + '日' + ' ' + [H, m, s].map(formt).join(':')
|
|
|
+ }
|
|
|
+ return formt(Y) + '年' + formt(M) + '月' + formt(D) + '日'
|
|
|
+ } else {
|
|
|
+ if (status) {
|
|
|
+ return [Y, M, D].map(formt).join(fmt) + ' ' + [H, m, s].map(formt).join(':')
|
|
|
+ }
|
|
|
+ return [Y, M, D].map(formt).join(fmt);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
return ''
|
|
|
}
|