We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 160bdec commit da791f3Copy full SHA for da791f3
app/src/core/time/time.hpp
@@ -3,6 +3,7 @@
3
#include <chrono>
4
#include <ctime>
5
#include <iomanip>
6
+#include <mutex>
7
#include <optional>
8
#include <sstream>
9
#include <string>
@@ -15,6 +16,8 @@ namespace fastchess::time {
15
16
17
namespace sc = std::chrono;
18
19
+inline std::mutex mutex_time;
20
+
21
// Get the current date and time in a given format.
22
[[nodiscard]] inline std::optional<std::string> datetime(const std::string &format) {
23
// Get the current time in UTC
@@ -43,6 +46,8 @@ namespace sc = std::chrono;
43
46
}
44
47
45
48
[[nodiscard]] inline std::string datetime_iso() {
49
+ std::lock_guard<std::mutex> lock(mutex_time);
50
51
auto now = std::chrono::system_clock::now();
52
auto now_c = std::chrono::system_clock::to_time_t(now);
53
0 commit comments