Skip to content

Commit ee13f24

Browse files
authored
Remove ctime header (#5)
* Add date dependency * Add date as dependency. * Replace legacy time with chrono time. (fixes tmakkonen#85) * Resolve some missing time function. (see tmakkonen#85)
1 parent 020d98d commit ee13f24

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

src/commands.cpp

+3-10
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <vector>
2323
#include <sstream>
2424
#include <cstring>
25-
#include <ctime>
2625
#include <cassert>
2726
#include <chrono>
2827

@@ -240,9 +239,7 @@ bool Answer::ParseCommand(
240239

241240
bool Answer::RunCommand(const std::string &loopsuffix) {
242241
std::cout << "## Answer ##" << std::endl;
243-
char buf[256];
244-
time_t secsnow = time(NULL);
245-
cout << "Answer: starting at " << ctime_r(&secsnow, buf) << endl;
242+
cout << "Answer: starting at " << system_clock::now() << endl;
246243

247244
// set up
248245
PString token;
@@ -287,9 +284,7 @@ bool Hangup::ParseCommand(
287284
bool Hangup::RunCommand(const std::string &loopsuffix) {
288285

289286
std::cout << "## Hangup ##" << std::endl;
290-
char buf[256];
291-
time_t secsnow = time(NULL);
292-
cout << "Hangup: at " << ctime_r(&secsnow, buf) << endl;
287+
cout << "Hangup: at " << system_clock::now() << endl;
293288
TPState &tpstate = TPState::Instance();
294289

295290
// hangup
@@ -597,12 +592,10 @@ bool Loop::RunCommand(const std::string &loopsuffix) {
597592

598593
int timesleft = 0;
599594
do {
600-
char buf[256];
601-
time_t secsnow = time(NULL);
602595
stringstream newsuffix;
603596
newsuffix << loopsuffix << "_" << timesleft;
604597
cout << "Loop: iteration \"" << newsuffix.str()
605-
<< "\" at " << ctime_r(&secsnow, buf) << endl;
598+
<< "\" at " << system_clock::now() << endl;
606599

607600
if(!Command::Run(loopedsequence, newsuffix.str()))
608601
return false;

0 commit comments

Comments
 (0)