summaryrefslogtreecommitdiff
path: root/louloulibs/utils
diff options
context:
space:
mode:
Diffstat (limited to 'louloulibs/utils')
-rw-r--r--louloulibs/utils/time.cpp12
-rw-r--r--louloulibs/utils/time.hpp9
2 files changed, 21 insertions, 0 deletions
diff --git a/louloulibs/utils/time.cpp b/louloulibs/utils/time.cpp
new file mode 100644
index 0000000..e23def4
--- /dev/null
+++ b/louloulibs/utils/time.cpp
@@ -0,0 +1,12 @@
+#include <utils/time.hpp>
+
+namespace utils
+{
+std::string to_string(const std::time_t& timestamp)
+{
+ constexpr std::size_t stamp_size = 20;
+ char date_buf[stamp_size];
+ std::strftime(date_buf, stamp_size, "%FT%TZ", std::gmtime(&timestamp));
+ return {std::begin(date_buf), std::end(date_buf)};
+}
+} \ No newline at end of file
diff --git a/louloulibs/utils/time.hpp b/louloulibs/utils/time.hpp
new file mode 100644
index 0000000..dff1250
--- /dev/null
+++ b/louloulibs/utils/time.hpp
@@ -0,0 +1,9 @@
+#pragma once
+
+#include <ctime>
+#include <string>
+
+namespace utils
+{
+std::string to_string(const std::time_t& timestamp);
+} \ No newline at end of file