Skip to content

Commit e8238ff

Browse files
committed
remove stringstreams from TimeUtils
1 parent 5ddaa9e commit e8238ff

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/utils/TimeUtils.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,8 @@ std::string TimeUtils::timeToString(time_t input) {
2828

2929
std::string TimeUtils::isoTimeToString(const std::string& input) {
3030
if(input.empty()) return "NA";
31-
std::string output;
32-
getline(std::istringstream(input), output, 'T');
33-
return output;
34-
/*int y,M,d;
35-
sscanf(input.c_str(), "%d-%d-%dT", &y, &M, &d);
36-
return fmt::format("{}-{:02}-{:02}", y, M, d);*/
31+
auto pos = input.find('T');
32+
return pos != std::string::npos ? input.substr(0, pos) : input;
3733
}
3834

3935
std::string TimeUtils::workingTime(int value){
@@ -44,12 +40,12 @@ std::string TimeUtils::workingTime(int value){
4440
int minutes = (value % 3600) / 60;
4541
int seconds = value % 60;
4642

47-
std::ostringstream stream;
48-
if(hours > 0) stream << hours << "h ";
49-
if(hours > 0 || minutes > 0) stream << minutes << "m ";
50-
stream << seconds << "s";
43+
std::string res;
44+
if(hours > 0) res += fmt::format("{}h ", hours);
45+
if(hours > 0 || minutes > 0) res += fmt::format("{}m ", minutes);
46+
res += fmt::format("{}s", seconds);
5147

52-
return stream.str();
48+
return res;
5349
}
5450

5551
std::string TimeUtils::platformerTime(int value, bool showMilliseconds){

0 commit comments

Comments
 (0)