时间处理公共方法
Showing
1 changed file
with
25 additions
and
0 deletions
... | @@ -109,4 +109,29 @@ export function down (index, data) { | ... | @@ -109,4 +109,29 @@ export function down (index, data) { |
109 | data.splice(index + 1, 1); | 109 | data.splice(index + 1, 1); |
110 | data.splice(index, 0, downData); | 110 | data.splice(index, 0, downData); |
111 | } | 111 | } |
112 | } | ||
113 | |||
114 | export function timeFormat(date) { | ||
115 | if (!date || typeof(date) === "string") { | ||
116 | this.error("参数异常,请检查..."); | ||
117 | } | ||
118 | var y = date.getFullYear(); //年 | ||
119 | var m = date.getMonth() + 1; //月 | ||
120 | var d = date.getDate(); //日 | ||
121 | return y + "/" + m + "/" + d + ' 00:00:00'; | ||
122 | } | ||
123 | export function getFirstDayOfSeason (d) { | ||
124 | let date = d || new Date() | ||
125 | var month = date.getMonth(); | ||
126 | if(month <3 ){ | ||
127 | date.setMonth(0); | ||
128 | }else if(2 < month && month < 6){ | ||
129 | date.setMonth(3); | ||
130 | }else if(5 < month && month < 9){ | ||
131 | date.setMonth(6); | ||
132 | }else if(8 < month && month < 11){ | ||
133 | date.setMonth(9); | ||
134 | } | ||
135 | date.setDate(1); | ||
136 | return timeFormat(date); | ||
112 | } | 137 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or sign in to post a comment