質問編集履歴
5
画像の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -161,3 +161,9 @@
|
|
161
161
|
/${ifHolidayDate.getDate()} (${weekdays[ifHolidayDate.getDay()]})`;
|
162
162
|
|
163
163
|
```
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
画像はjavascriptのエラー文です。
|
168
|
+
|
169
|
+
![イメージ説明](db2474875e0679c14db2223b4d2fc3db.png)
|
4
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -26,36 +26,138 @@
|
|
26
26
|
|
27
27
|
|
28
28
|
|
29
|
-
--追記--
|
29
|
+
--追記3--
|
30
30
|
|
31
|
-
お二方の回答で<script>をいれましたが反応がありませんでした。
|
31
|
+
お二方様の回答で<script>をいれましたが反応がありませんでした。
|
32
32
|
|
33
|
-
|
33
|
+
javascriptにエラー文が出ていますが空白を入れたら直るものばかりでしたのでコードは空白を入れた以外何も触っていません。
|
34
34
|
|
35
|
-
|
35
|
+
変更した後のを貼ったほうが良いとのことでしたので、<script>を入れたhtmlとjavascriptを載せます。
|
36
|
-
|
37
|
-
```ここに言語を入力
|
38
36
|
|
39
37
|
|
40
38
|
|
41
|
-
|
39
|
+
```html
|
42
40
|
|
43
|
-
doc
|
41
|
+
<!doctype html>
|
44
42
|
|
43
|
+
<html lang="ja">
|
44
|
+
|
45
|
+
<head>
|
46
|
+
|
47
|
+
<meta charset="UTF-8">
|
48
|
+
|
49
|
+
<script src=javascript/test2.js></script>
|
50
|
+
|
51
|
+
<title>demo</title>
|
52
|
+
|
53
|
+
</head>
|
54
|
+
|
55
|
+
<body>
|
56
|
+
|
57
|
+
<main>
|
58
|
+
|
59
|
+
<p>ページを開いた日時: <span id="today"></span></p>
|
60
|
+
|
61
|
+
<p>3週間後: <span id="after3weeks"></span></p>
|
62
|
+
|
45
|
-
|
63
|
+
<p>3週間後が祝日ならその次の日: <span id="after3weeksIfHoliday"></span></p>
|
64
|
+
|
65
|
+
</main>
|
66
|
+
|
67
|
+
</body>
|
68
|
+
|
69
|
+
</html>
|
70
|
+
|
71
|
+
```
|
46
72
|
|
47
73
|
|
48
74
|
|
49
|
-
```
|
75
|
+
```javascript
|
50
76
|
|
51
|
-
|
77
|
+
const weekdays = ['日', '月', '火', '水', '木', '金', '土'];
|
52
|
-
|
53
|
-
こちらも教えていただけたらと思います。
|
54
78
|
|
55
79
|
|
56
80
|
|
57
|
-
|
81
|
+
// https://www8.cao.go.jp/chosei/shukujitsu/syukujitsu.csv
|
58
82
|
|
59
|
-
|
83
|
+
const holidaysCsvFromCabinetOffice = `国民の祝日・休日月日,国民の祝日・休日名称
|
60
84
|
|
85
|
+
2020/1/1,元日
|
86
|
+
|
61
|
-
|
87
|
+
2020/1/13,成人の日
|
88
|
+
|
89
|
+
2020/2/11,建国記念の日
|
90
|
+
|
91
|
+
2020/2/23,天皇誕生日
|
92
|
+
|
93
|
+
2020/2/24,休日
|
94
|
+
|
95
|
+
2020/3/20,春分の日
|
96
|
+
|
97
|
+
2020/4/29,昭和の日
|
98
|
+
|
99
|
+
2020/5/3,憲法記念日
|
100
|
+
|
101
|
+
2020/5/4,みどりの日
|
102
|
+
|
103
|
+
2020/5/5,こどもの日
|
104
|
+
|
105
|
+
2020/5/6,休日
|
106
|
+
|
107
|
+
2020/7/23,海の日
|
108
|
+
|
109
|
+
2020/7/24,スポーツの日
|
110
|
+
|
111
|
+
2020/8/10,山の日
|
112
|
+
|
113
|
+
2020/9/21,敬老の日
|
114
|
+
|
115
|
+
2020/9/22,秋分の日
|
116
|
+
|
117
|
+
2020/11/3,文化の日
|
118
|
+
|
119
|
+
2020/11/23,勤労感謝の日
|
120
|
+
|
121
|
+
`.split(/\r\n+/).map(row => row.split(',')[0]);
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
const now = Date.now();
|
126
|
+
|
127
|
+
const today = new Date(now);
|
128
|
+
|
129
|
+
const afterThreeWeek = new Date(now + 3 * 7 * 24 * 60 * 60 * 1000);
|
130
|
+
|
131
|
+
// 3週 * 7日 * 24時間 * 60分 * 60秒 * 1000ミリ秒
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
let ifHolidayDate = new Date(afterThreeWeek.getTime());
|
136
|
+
|
137
|
+
while (holidaysCsvFromCabinetOffice.indexOf(`${ifHolidayDate.getFullYear()}
|
138
|
+
|
139
|
+
/${ifHolidayDate.getMonth() + 1}/${ifHolidayDate.getDate()}`) !== -1) {
|
140
|
+
|
141
|
+
ifHolidayDate = new Date(ifHolidayDate.getTime() + 24 * 60 * 60 * 1000);
|
142
|
+
|
143
|
+
}
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
document.getElementById('today').textContent = `${today.getFullYear()}
|
148
|
+
|
149
|
+
/${today.getMonth() + 1}/${today.getDate()} (${weekdays[today.getDay()]})`;
|
150
|
+
|
151
|
+
document.getElementById('after3weeks').textContent =
|
152
|
+
|
153
|
+
`${afterThreeWeek.getFullYear()}/${afterThreeWeek.getMonth() + 1}
|
154
|
+
|
155
|
+
/${afterThreeWeek.getDate()} (${weekdays[afterThreeWeek.getDay()]})`;
|
156
|
+
|
157
|
+
document.getElementById('after3weeksIfHoliday').textContent =
|
158
|
+
|
159
|
+
`${ifHolidayDate.getFullYear()}/${ifHolidayDate.getMonth() + 1}
|
160
|
+
|
161
|
+
/${ifHolidayDate.getDate()} (${weekdays[ifHolidayDate.getDay()]})`;
|
162
|
+
|
163
|
+
```
|
3
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -51,3 +51,11 @@
|
|
51
51
|
書かれているエラー文は大体同じで「required Space After Binary Operators:Operator + should not stick to preceding expression」が多いです。翻訳すると「二項演算子の後に必要なスペース:演算子+は前の表現に固執すべきではありません」ということみたいなのですが、正直何が原因なのかが全く分かりません。
|
52
52
|
|
53
53
|
こちらも教えていただけたらと思います。
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
--追記2--
|
58
|
+
|
59
|
+
すみません、『()+1』を『() + 1』にするとエラーが消えました。
|
60
|
+
|
61
|
+
しかしエラー文を消しても何も反応がないままです。
|
2
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -21,3 +21,33 @@
|
|
21
21
|
![Atom](82b992411ae3abbfa7a6649e957dce59.png)
|
22
22
|
|
23
23
|
![JSFiddle](4aa0712c66bddcee805afde27b949e4c.png)
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
--追記--
|
30
|
+
|
31
|
+
お二方の回答で<script>をいれましたが反応がありませんでした。
|
32
|
+
|
33
|
+
htmlでもないとするとjavascriptで何か問題があるのでしょうか。
|
34
|
+
|
35
|
+
![イメージ説明](f4ffbb98b570fa1f58768485e0df859d.png)
|
36
|
+
|
37
|
+
```ここに言語を入力
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
document.getElementById('today').textContent = `${today.getFullYear()}/${today.getMonth()+1}/${today.getDate()} (${weekdays[today.getDay()]})`;
|
42
|
+
|
43
|
+
document.getElementById('after3weeks').textContent = `${afterThreeWeek.getFullYear()}/${afterThreeWeek.getMonth()+1}/${afterThreeWeek.getDate()} (${weekdays[afterThreeWeek.getDay()]})`;
|
44
|
+
|
45
|
+
document.getElementById('after3weeksIfHoliday').textContent = `${ifHolidayDate.getFullYear()}/${ifHolidayDate.getMonth()+1}/${ifHolidayDate.getDate()} (${weekdays[ifHolidayDate.getDay()]})`;
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
```
|
50
|
+
|
51
|
+
書かれているエラー文は大体同じで「required Space After Binary Operators:Operator + should not stick to preceding expression」が多いです。翻訳すると「二項演算子の後に必要なスペース:演算子+は前の表現に固執すべきではありません」ということみたいなのですが、正直何が原因なのかが全く分かりません。
|
52
|
+
|
53
|
+
こちらも教えていただけたらと思います。
|
1
文の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
webで確認しても出てきませんでした。
|
4
4
|
|
5
|
-
JSFiddleとJS Binというサイトで
|
5
|
+
JSFiddleとJS Binという2つのサイトで試すと反応しました。
|
6
6
|
|
7
7
|
|
8
8
|
|