mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-22 18:17:40 +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 "save_index.hpp"
|
||||||
#include "saved_game.hpp"
|
#include "saved_game.hpp"
|
||||||
#include "serialization/binary_or_text.hpp"
|
#include "serialization/binary_or_text.hpp"
|
||||||
|
#include "serialization/chrono.hpp"
|
||||||
#include "serialization/utf8_exception.hpp"
|
#include "serialization/utf8_exception.hpp"
|
||||||
#include "utils/optimer.hpp"
|
#include "utils/optimer.hpp"
|
||||||
#include "video.hpp" // only for faked
|
#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
|
std::string replay_savegame::create_initial_filename(unsigned int) const
|
||||||
{
|
{
|
||||||
time_t t = std::time(nullptr);
|
auto time = chrono::format_local_timestamp(std::chrono::system_clock::now(), "%Y%m%d-%H%M%S");
|
||||||
tm tm = *std::localtime(&t);
|
|
||||||
auto time = std::put_time(&tm, "%Y%m%d-%H%M%S");
|
|
||||||
|
|
||||||
// TRANSLATORS: This string is used as part of a filename, as in, "HttT-The Elves Besieged replay.gz"
|
// 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;
|
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
|
const std::string& duration, std::chrono::system_clock::time_point start_time) const
|
||||||
{
|
{
|
||||||
if(duration.substr(0, 4) == "TIME") {
|
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;
|
std::size_t number = 0;
|
||||||
for(auto i = duration.begin() + 4; i != duration.end(); ++i) {
|
for(auto i = duration.begin() + 4; i != duration.end(); ++i) {
|
||||||
if(is_digit(*i)) {
|
if(is_digit(*i)) {
|
||||||
@ -343,22 +340,22 @@ std::pair<bool, utils::optional<std::chrono::system_clock::time_point>> ban_mana
|
|||||||
} else {
|
} else {
|
||||||
switch(*i) {
|
switch(*i) {
|
||||||
case 'Y':
|
case 'Y':
|
||||||
loc->tm_year = number;
|
start_time += chrono::years{number};
|
||||||
break;
|
break;
|
||||||
case 'M':
|
case 'M':
|
||||||
loc->tm_mon = number;
|
start_time += chrono::months{number};
|
||||||
break;
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
loc->tm_mday = number;
|
start_time += chrono::days{number};
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
loc->tm_hour = number;
|
start_time += std::chrono::hours{number};
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
loc->tm_min = number;
|
start_time += std::chrono::minutes{number};
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
loc->tm_sec = number;
|
start_time += std::chrono::seconds{number};
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOG_SERVER << "Invalid time modifier given: '" << *i << "'.";
|
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;
|
number = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { true, std::chrono::system_clock::from_time_t(std::mktime(loc)) };
|
return { true, start_time };
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string dur_lower;
|
std::string dur_lower;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user