@@ -105,7 +105,7 @@ int main()
105
105
106
106
#### 出力例
107
107
```
108
- 2019-10-24 11:15:27 GPS
108
+ 2019-10-24 11:15:27
109
109
```
110
110
111
111
### 入力の例
@@ -128,32 +128,35 @@ int main()
128
128
129
129
if (ss) {
130
130
std::cout << tp << std::endl;
131
- }
132
- else {
131
+ } else {
133
132
std::cout << "解析失敗" << std::endl;
134
133
}
135
134
}
136
135
137
136
// タイムゾーンを含む入力
138
137
{
139
138
std::stringstream ss;
140
- ss << "2019-10-24 20:15:10 GPS";
139
+ ss << "2019-10-24 20:15:27 GPS";
141
140
142
141
chrono::gps_seconds tp;
143
142
std::string abbrev;
144
- chrono::from_stream(ss, "%Y-%m-%d %H:%M:%S %Z%z ", tp, &abbrev);
143
+ chrono::from_stream(ss, "%Y-%m-%d %H:%M:%S %Z", tp, &abbrev);
145
144
146
- std::cout << tp << std::endl;
147
- std::cout << abbrev << std::endl;
145
+ if (ss) {
146
+ std::cout << tp << std::endl;
147
+ std::cout << abbrev << std::endl;
148
+ } else {
149
+ std::cout << "解析失敗" << std::endl;
150
+ }
148
151
}
149
152
}
150
153
```
151
154
* chrono::from_stream[color ff0000]
152
155
153
- #### 出力例
156
+ #### 出力
154
157
```
155
- 2019-10-24 11 :15:27 GPS
156
- 2019-10-24 11 :15:27 GPS
158
+ 2019-10-24 20 :15:45
159
+ 2019-10-24 20 :15:45
157
160
GPS
158
161
```
159
162
@@ -168,7 +171,7 @@ namespace chrono = std::chrono;
168
171
int main()
169
172
{
170
173
chrono::gps_clock::time_point now = chrono::gps_clock::now();
171
- chrono::gps_seconds now_sec = chrono::floor<chrono::seconds>(tp );
174
+ chrono::gps_seconds now_sec = chrono::floor<chrono::seconds>(now );
172
175
173
176
// デフォルトフォーマット
174
177
std::cout << std::format("1 : {}", now_sec) << std::endl;
@@ -177,25 +180,25 @@ int main()
177
180
std::cout << std::format("2 : {:%Y年%m月%d日 %H時%M分%S秒}", now_sec) << std::endl;
178
181
179
182
// 日付を / (スラッシュ) 区切り、時間を : (コロン) 区切り、タイムゾーンの略称付き
180
- std::cout << std::format("3 : {0 :%Y/%m/%d %H:%M:%S %Z}", now_sec) << std::endl;
183
+ std::cout << std::format("3 : {:%Y/%m/%d %H:%M:%S %Z}", now_sec) << std::endl;
181
184
182
185
// 日付だけ出力
183
- std::cout << std::format("4 : %Y年%m月%d日", now_sec) << std::endl;
184
- std::cout << std::format("5 : %F ", now_sec) << std::endl;
186
+ std::cout << std::format("4 : {: %Y年%m月%d日} ", now_sec) << std::endl;
187
+ std::cout << std::format("5 : {:%F} ", now_sec) << std::endl;
185
188
186
189
// 時間だけ出力
187
- std::cout << std::format("6 : %H時%M分%S秒", now_sec) << std::endl;
188
- std::cout << std::format("7 : %T ", now_sec) << std::endl;
190
+ std::cout << std::format("6 : {: %H時%M分%S秒} ", now_sec) << std::endl;
191
+ std::cout << std::format("7 : {:%T} ", now_sec) << std::endl;
189
192
}
190
193
```
191
194
* chrono::gps_clock[ link gps_clock.md]
192
195
* now()[ link gps_clock/now.md]
193
196
* chrono::floor[ link time_point/floor.md]
194
197
* std::format[ link format.md]
195
198
196
- #### 出力例
199
+ #### 出力
197
200
```
198
- 1 : 2019-12-20 10:05:05 GPS
201
+ 1 : 2019-12-20 10:05:05
199
202
2 : 2019年12月20日 10時05分05秒
200
203
3 : 2019/12/20 10:05:05 GPS
201
204
4 : 2019年12月20日
@@ -204,13 +207,14 @@ int main()
204
207
7 : 10:05:05
205
208
```
206
209
210
+
207
211
## バージョン
208
212
### 言語
209
213
- C++20
210
214
211
215
### 処理系
212
216
- [ Clang] ( /implementation.md#clang ) : 9.0 [ mark noimpl]
213
- - [ GCC] ( /implementation.md#gcc ) : 9.2 [ mark noimpl]
217
+ - [ GCC] ( /implementation.md#gcc ) : 9.2 [ mark noimpl] , 14.1 [ mark verified ]
214
218
- [ Visual C++] ( /implementation.md#visual_cpp ) : 2019 Update 3 [ mark noimpl]
215
219
216
220
0 commit comments