RSTools 3.1.0
Versatile C++20 utility library
Loading...
Searching...
No Matches
DateTime.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <chrono>
4#include <cstdint>
5#include <string>
6#include <string_view>
7
8namespace RST::Time {
9
11 enum class TimeZone : std::uint8_t { Local, Utc };
12
14 [[nodiscard]] std::string formatTime(std::chrono::system_clock::time_point time, std::string_view format = "%Y-%m-%d %H:%M:%S", TimeZone zone = TimeZone::Local);
15
17 [[nodiscard]] std::string formatNow(std::string_view format = "%Y-%m-%d %H:%M:%S", TimeZone zone = TimeZone::Local);
18}
Stopwatch, frame timing and date formatting.
Definition DateTime.hpp:8
std::string formatNow(std::string_view format="%Y-%m-%d %H:%M:%S", TimeZone zone=TimeZone::Local)
Formats the current time; see formatTime().
std::string formatTime(std::chrono::system_clock::time_point time, std::string_view format="%Y-%m-%d %H:%M:%S", TimeZone zone=TimeZone::Local)
Formats time with std::strftime codes, such as Y-m-d H:M:S; returns an empty string on failure.
TimeZone
Time zone used to format dates.
Definition DateTime.hpp:11