bddcf056 by yangwei

时间处理公共方法

1 parent f2804a5b
......@@ -109,4 +109,29 @@ export function down (index, data) {
data.splice(index + 1, 1);
data.splice(index, 0, downData);
}
}
export function timeFormat(date) {
if (!date || typeof(date) === "string") {
this.error("参数异常,请检查...");
}
var y = date.getFullYear(); //年
var m = date.getMonth() + 1; //月
var d = date.getDate(); //日
return y + "/" + m + "/" + d + ' 00:00:00';
}
export function getFirstDayOfSeason (d) {
let date = d || new Date()
var month = date.getMonth();
if(month <3 ){
date.setMonth(0);
}else if(2 < month && month < 6){
date.setMonth(3);
}else if(5 < month && month < 9){
date.setMonth(6);
}else if(8 < month && month < 11){
date.setMonth(9);
}
date.setDate(1);
return timeFormat(date);
}
\ No newline at end of file
......