mirror of
https://github.com/open-goal/jak-project
synced 2026-05-25 23:35:33 -04:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user