Fix Axis | season title | clean up

This commit is contained in:
ptmaster
2024-12-22 00:02:50 +08:00
parent 32512d0dbc
commit 2267d82790
8 changed files with 180 additions and 194 deletions
+14 -2
View File
@@ -104,7 +104,7 @@ readConfigIntArray (const toml_table_t *table, const std::string &key, std::vect
}
std::wstring
replace (const std::wstring &orignStr, const std::wstring &oldStr, const std::wstring &newStr) {
replace (const std::wstring orignStr, const std::wstring &oldStr, const std::wstring &newStr) {
size_t pos = 0;
std::wstring tempStr = orignStr;
const std::wstring::size_type newStrLen = newStr.length ();
@@ -121,7 +121,7 @@ replace (const std::wstring &orignStr, const std::wstring &oldStr, const std::ws
}
std::string
replace (const std::string &orignStr, const std::string &oldStr, const std::string &newStr) {
replace (const std::string orignStr, const std::string &oldStr, const std::string &newStr) {
size_t pos = 0;
std::string tempStr = orignStr;
const std::string::size_type newStrLen = newStr.length ();
@@ -200,4 +200,16 @@ withFile (const char *fileName, std::function<void (u8 *)> callback) {
free (buffer);
fclose (file);
}
std::string
season () {
std::time_t time = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
std::tm* tm = std::localtime(&time);
int month = tm->tm_mon + 1;
return std::to_string (tm->tm_year + 1900) + (
(month >= 3 && month <= 5) ? "spr" :
(month >= 6 && month <= 8) ? "sum" :
(month >= 9 && month <= 11) ? "aut" : "win"
);
}