mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-22 19:36:04 +00:00
caught a few more things
This commit is contained in:
parent
7fdcdb86d2
commit
13d83e5665
@ -38,6 +38,7 @@
|
||||
#include "save_index.hpp"
|
||||
#include "saved_game.hpp"
|
||||
#include "serialization/binary_or_text.hpp"
|
||||
#include "serialization/chrono.hpp"
|
||||
#include "serialization/utf8_exception.hpp"
|
||||
#include "utils/optimer.hpp"
|
||||
#include "video.hpp" // only for faked
|
||||
@ -572,10 +573,7 @@ replay_savegame::replay_savegame(saved_game& gamestate, const compression::forma
|
||||
|
||||
std::string replay_savegame::create_initial_filename(unsigned int) const
|
||||
{
|
||||
time_t t = std::time(nullptr);
|
||||
tm tm = *std::localtime(&t);
|
||||
auto time = std::put_time(&tm, "%Y%m%d-%H%M%S");
|
||||
|
||||
auto time = chrono::format_local_timestamp(std::chrono::system_clock::now(), "%Y%m%d-%H%M%S");
|
||||
// TRANSLATORS: This string is used as part of a filename, as in, "HttT-The Elves Besieged replay.gz"
|
||||
return formatter() << gamestate().classification().label << " " << _("replay") << " " << time;
|
||||
}
|
||||
|
@ -333,9 +333,6 @@ std::pair<bool, utils::optional<std::chrono::system_clock::time_point>> ban_mana
|
||||
const std::string& duration, std::chrono::system_clock::time_point start_time) const
|
||||
{
|
||||
if(duration.substr(0, 4) == "TIME") {
|
||||
auto as_time_t = std::chrono::system_clock::to_time_t(start_time);
|
||||
std::tm* loc = std::localtime(&as_time_t);
|
||||
|
||||
std::size_t number = 0;
|
||||
for(auto i = duration.begin() + 4; i != duration.end(); ++i) {
|
||||
if(is_digit(*i)) {
|
||||
@ -343,22 +340,22 @@ std::pair<bool, utils::optional<std::chrono::system_clock::time_point>> ban_mana
|
||||
} else {
|
||||
switch(*i) {
|
||||
case 'Y':
|
||||
loc->tm_year = number;
|
||||
start_time += chrono::years{number};
|
||||
break;
|
||||
case 'M':
|
||||
loc->tm_mon = number;
|
||||
start_time += chrono::months{number};
|
||||
break;
|
||||
case 'D':
|
||||
loc->tm_mday = number;
|
||||
start_time += chrono::days{number};
|
||||
break;
|
||||
case 'h':
|
||||
loc->tm_hour = number;
|
||||
start_time += std::chrono::hours{number};
|
||||
break;
|
||||
case 'm':
|
||||
loc->tm_min = number;
|
||||
start_time += std::chrono::minutes{number};
|
||||
break;
|
||||
case 's':
|
||||
loc->tm_sec = number;
|
||||
start_time += std::chrono::seconds{number};
|
||||
break;
|
||||
default:
|
||||
LOG_SERVER << "Invalid time modifier given: '" << *i << "'.";
|
||||
@ -367,7 +364,7 @@ std::pair<bool, utils::optional<std::chrono::system_clock::time_point>> ban_mana
|
||||
number = 0;
|
||||
}
|
||||
}
|
||||
return { true, std::chrono::system_clock::from_time_t(std::mktime(loc)) };
|
||||
return { true, start_time };
|
||||
}
|
||||
|
||||
std::string dur_lower;
|
||||
|
Loading…
x
Reference in New Issue
Block a user