game: Migrate from GLFW to SDL2 & attempt to rewrite / simplify display and input code (#2397)

Co-authored-by: Hat Kid <6624576+Hat-Kid@users.noreply.github.com>
This commit is contained in:
Tyler Wilding
2023-06-04 14:34:37 -05:00
committed by GitHub
parent 08741f0a42
commit bdaf088d4b
1973 changed files with 903017 additions and 118529 deletions
+41
View File
@@ -1,7 +1,9 @@
#include "string_util.h"
#include <iomanip>
#include <random>
#include <regex>
#include <sstream>
#include "common/util/diff.h"
@@ -141,4 +143,43 @@ std::string repeat(size_t n, const std::string& str) {
ret.append(ret.c_str(), (n - (m / 2)) * period);
return ret;
}
std::string current_local_timestamp() {
std::time_t now = std::time(nullptr);
std::tm local_time = *std::localtime(&now);
const std::string format = "%Y-%m-%dT%H:%M:%S";
std::ostringstream oss;
oss << std::put_time(&local_time, format.c_str());
return oss.str();
}
std::string current_local_timestamp_no_colons() {
std::time_t now = std::time(nullptr);
std::tm local_time = *std::localtime(&now);
const std::string format = "%Y-%m-%dT%H-%M-%S";
std::ostringstream oss;
oss << std::put_time(&local_time, format.c_str());
return oss.str();
}
std::string current_isotimestamp() {
std::time_t now = std::time(nullptr);
std::tm utc_time = *std::gmtime(&now);
const std::string format = "%Y-%m-%dT%H:%M:%SZ";
std::ostringstream oss;
oss << std::put_time(&utc_time, format.c_str());
return oss.str();
}
std::string to_upper(const std::string& str) {
std::string new_str(str.size(), ' ');
std::transform(str.begin(), str.end(), new_str.begin(), ::toupper);
return new_str;
}
std::string to_lower(const std::string& str) {
std::string new_str(str.size(), ' ');
std::transform(str.begin(), str.end(), new_str.begin(), ::tolower);
return new_str;
}
} // namespace str_util