回答編集履歴

2

チョウセイ

2022/08/09 05:08

投稿

yambejp
yambejp

スコア114885

test CHANGED
@@ -11,23 +11,23 @@
11
11
  const a={
12
12
  "1":{
13
13
  "quarter": 1,
14
- "start": new Date(y,m-1).getMonth()+1,
14
+ "start": new Date(y,m ,0).getMonth()+1,
15
- "end": new Date(y,m+1+2).getMonth()+1,
15
+ "end": new Date(y,m+2,0).getMonth()+1,
16
16
  },
17
17
  "2":{
18
18
  "quarter": 2,
19
- "start": new Date(y,m-1+3).getMonth()+1,
19
+ "start": new Date(y,m +3,0).getMonth()+1,
20
- "end": new Date(y,m+1+3).getMonth()+1,
20
+ "end": new Date(y,m+2+3,0).getMonth()+1,
21
21
  },
22
22
  "3":{
23
23
  "quarter": 3,
24
- "start": new Date(y,m-1+6).getMonth()+1,
24
+ "start": new Date(y,m +6,0).getMonth()+1,
25
- "end": new Date(y,m+1+6).getMonth()+1,
25
+ "end": new Date(y,m+2+6,0).getMonth()+1,
26
26
  },
27
27
  "4":{
28
28
  "quarter": 4,
29
- "start": new Date(y,m-1+9).getMonth()+1,
29
+ "start": new Date(y,m +9,0).getMonth()+1,
30
- "end": new Date(y,m+1+9).getMonth()+1,
30
+ "end": new Date(y,m+2+9,0).getMonth()+1,
31
31
  },
32
32
  }
33
33
  console.log(a);

1

チョウセイ

2022/08/09 05:05

投稿

yambejp
yambejp

スコア114885

test CHANGED
@@ -4,3 +4,31 @@
4
4
  - 2Q:2022年8月~2022年10月
5
5
  - 3Q:2022年11月~2022年13月
6
6
  - 4Q:2022年14月~2022年16月
7
+
8
+ ```javascript
9
+ const y=2022;
10
+ const m=5;
11
+ const a={
12
+ "1":{
13
+ "quarter": 1,
14
+ "start": new Date(y,m-1).getMonth()+1,
15
+ "end": new Date(y,m+1+2).getMonth()+1,
16
+ },
17
+ "2":{
18
+ "quarter": 2,
19
+ "start": new Date(y,m-1+3).getMonth()+1,
20
+ "end": new Date(y,m+1+3).getMonth()+1,
21
+ },
22
+ "3":{
23
+ "quarter": 3,
24
+ "start": new Date(y,m-1+6).getMonth()+1,
25
+ "end": new Date(y,m+1+6).getMonth()+1,
26
+ },
27
+ "4":{
28
+ "quarter": 4,
29
+ "start": new Date(y,m-1+9).getMonth()+1,
30
+ "end": new Date(y,m+1+9).getMonth()+1,
31
+ },
32
+ }
33
+ console.log(a);
34
+ ```