18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-27 21:45:16 +01:00

refactor: the dates of the scenery wizard and of the editor's backups through std::format, ranges all_of (Sonar S6229, S6197)

This commit is contained in:
jerrrrycho
2026-11-16 07:25:04 +01:00
parent 57c723a72e
commit cff1232cce
3 changed files with 5 additions and 5 deletions

View File

@@ -26,6 +26,7 @@ http://mozilla.org/MPL/2.0/.
#include <cstdio>
#include <ctime>
#include <filesystem>
#include <format>
#include <fstream>
namespace
@@ -400,9 +401,8 @@ bool ui::scenerywizard_panel::create_scenery()
return false;
}
auto const now{std::time(nullptr)};
char date[32];
std::tm const local{local_tm(now)};
std::strftime(date, sizeof(date), "%Y-%m-%d", &local);
auto const date{std::format("{:04}-{:02}-{:02}", local.tm_year + 1900, local.tm_mon + 1, local.tm_mday)};
char reference[96];
std::snprintf(reference, sizeof(reference), "//$g PUWG1992 %.3f %.3f", m_map.point().x / 1000.0, m_map.point().y / 1000.0);
auto const area{range()};

View File

@@ -27,6 +27,7 @@ http://mozilla.org/MPL/2.0/.
#include "utilities/translation.h"
#include "editor/editorFormat.hpp"
#include <format>
#include <map>
#include <optional>
#include <set>
@@ -1667,9 +1668,8 @@ save_result node_layers::save(std::vector<std::string> const &Rootstatements, st
// without the copy nothing is replaced
{
auto const now{std::time(nullptr)};
char stamp[32];
std::tm const local{local_tm(now)};
std::strftime(stamp, sizeof(stamp), "%Y%m%d-%H%M%S", &local);
auto const stamp{std::format("{:04}{:02}{:02}-{:02}{:02}{:02}", local.tm_year + 1900, local.tm_mon + 1, local.tm_mday, local.tm_hour, local.tm_min, local.tm_sec)};
for (auto const output : written)
{
auto const filepath{path(output)};

View File

@@ -208,7 +208,7 @@ node_groups::update_map()
last_switch->track[lastc - 'a'] = track;
// all four tracks of the cross switch have to be known before it's assigned
if (!std::all_of(last_switch->track.begin(), last_switch->track.end(), [](TTrack const *Track) { return Track != nullptr; }))
if (!std::ranges::all_of(last_switch->track, [](TTrack const *Track) { return Track != nullptr; }))
continue;
if (!assign_cross_switch(*last_switch, sw_name, "ac", 0))