Skip to content

Commit

Permalink
moved timestamp function to time_tools.h
Browse files Browse the repository at this point in the history
  • Loading branch information
EricPlayZ committed Jul 5, 2023
1 parent ef4c605 commit 1e73647
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 0 additions & 12 deletions DL2FOVOverhaul/source/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,6 @@
#include "time_tools.h"
#include "SigScan\StaticOffsets.h"

static std::ostringstream GetTimestamp() {
time_t timeInstance = time(0);
tm timestamp{};
localtime_s(&timestamp, &timeInstance);
std::ostringstream oss{};
oss << "[" << std::setw(2) << std::setfill('0') << timestamp.tm_hour << "h:"
<< std::setw(2) << std::setfill('0') << timestamp.tm_min << "m:"
<< std::setw(2) << std::setfill('0') << timestamp.tm_sec << "s] ";

return oss;
}

CLobbySteam* CLobbySteamInstance = NULL;
CGame* CGameInstance = NULL;
PlayerVariables* PlayerVariablesInstance = NULL;
Expand Down
12 changes: 12 additions & 0 deletions DL2FOVOverhaul/source/time_tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,16 @@

template <class result_t = std::chrono::milliseconds, class clock_t = std::chrono::steady_clock, class duration_t = std::chrono::milliseconds> auto since(std::chrono::time_point<clock_t, duration_t> const& start) {
return std::chrono::duration_cast<result_t>(clock_t::now() - start);
}

inline std::ostringstream GetTimestamp() {
time_t timeInstance = time(0);
tm timestamp{};
localtime_s(&timestamp, &timeInstance);
std::ostringstream oss{};
oss << "[" << std::setw(2) << std::setfill('0') << timestamp.tm_hour << "h:"
<< std::setw(2) << std::setfill('0') << timestamp.tm_min << "m:"
<< std::setw(2) << std::setfill('0') << timestamp.tm_sec << "s] ";

return oss;
}

0 comments on commit 1e73647

Please sign in to comment.