teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

微調整

2021/12/22 04:22

投稿

nanase21
nanase21

スコア144

title CHANGED
File without changes
body CHANGED
@@ -7,10 +7,10 @@
7
7
  const dt = new Date('2021-12-22T09:00:00.000Z');
8
8
  // 各月の1日を取得
9
9
  const pdtf = new Date(dt.getFullYear(), dt.getMonth() - 1, 1, 0, 0, 1); // 先月
10
- const tdtf = new Date(dt.getFullYear(), dt.getMonth(), 1,   0, 0, 1);      // 今月
10
+ const tdtf = new Date(dt.getFullYear(), dt.getMonth(),   1,   0, 0, 1);      // 今月
11
11
  const ndtf = new Date(dt.getFullYear(), dt.getMonth() + 1, 1, 0, 0, 1); // 来月
12
12
  // 各月の末日を取得
13
- const pdtl = new Date(dt.getFullYear(), dt.getMonth(), 0,   0, 23, 59, 59);  // 先月
13
+ const pdtl = new Date(dt.getFullYear(), dt.getMonth(),   0,   0, 23, 59, 59);  // 先月
14
14
  const tdtl = new Date(dt.getFullYear(), dt.getMonth() + 1, 0, 23, 59, 59); // 今月
15
15
  const ndtl = new Date(dt.getFullYear(), dt.getMonth() + 2, 0, 23, 59, 59); // 来月
16
16
  console.log(dt)

1

コードを読みやすく微調整した

2021/12/22 04:22

投稿

nanase21
nanase21

スコア144

title CHANGED
File without changes
body CHANGED
@@ -7,10 +7,10 @@
7
7
  const dt = new Date('2021-12-22T09:00:00.000Z');
8
8
  // 各月の1日を取得
9
9
  const pdtf = new Date(dt.getFullYear(), dt.getMonth() - 1, 1, 0, 0, 1); // 先月
10
- const tdtf = new Date(dt.getFullYear(), dt.getMonth(), 1, 0, 0, 1);        // 今月
10
+ const tdtf = new Date(dt.getFullYear(), dt.getMonth(), 1,   0, 0, 1);      // 今月
11
11
  const ndtf = new Date(dt.getFullYear(), dt.getMonth() + 1, 1, 0, 0, 1); // 来月
12
12
  // 各月の末日を取得
13
- const pdtl = new Date(dt.getFullYear(), dt.getMonth(), 0, 23, 59, 59);         // 先月
13
+ const pdtl = new Date(dt.getFullYear(), dt.getMonth(), 0,   0, 23, 59, 59);  // 先月
14
14
  const tdtl = new Date(dt.getFullYear(), dt.getMonth() + 1, 0, 23, 59, 59); // 今月
15
15
  const ndtl = new Date(dt.getFullYear(), dt.getMonth() + 2, 0, 23, 59, 59); // 来月
16
16
  console.log(dt)