|
@@ -7,20 +7,17 @@ function formatDate(time, flag) {
|
|
|
const day = tf(t.getDate());
|
|
|
const hour = tf(t.getHours());
|
|
|
const minute = tf(t.getMinutes());
|
|
|
- //console.log( month + '月' + day + '日' + hour + ':' + minute);
|
|
|
- if(flag == 1) {
|
|
|
- return month + '月' + day + '日' + ' ' + hour + ':' + minute;
|
|
|
- }else if(flag == 2) {
|
|
|
- return year + '-' + month + '-' + day
|
|
|
- }else if(flag == 3){
|
|
|
- return month + '-' + day + ' ' + hour + ':' + minute;
|
|
|
- }else if( flag == 4) {
|
|
|
- return year + '年' + month + '月' + day + '日';
|
|
|
- }else if( flag == 5){
|
|
|
- return day.toString().substring(1,2)
|
|
|
- }else if( flag == 6) {
|
|
|
- return month + '.' + day ;
|
|
|
- }
|
|
|
+ const seconds = tf(t.getSeconds());
|
|
|
+ const map = new Map([
|
|
|
+ [1, month + '月' + day + '日' + ' ' + hour + ':' + minute],
|
|
|
+ [2, year + '-' + month + '-' + day],
|
|
|
+ [3, month + '-' + day + ' ' + hour + ':' + minute],
|
|
|
+ [4, year + '年' + month + '月' + day + '日'],
|
|
|
+ [5, day.toString().substring(1,2)],
|
|
|
+ [6, month + '.' + day],
|
|
|
+ [7, year + '年' + month + '月' + day + '日' + hour + '时' + minute + '分' + seconds + '秒']
|
|
|
+ ])
|
|
|
+ return map.has(flag) && map.get(flag)
|
|
|
}
|
|
|
|
|
|
export default formatDate
|