https://godbolt.org/z/K57q45Y1v
#include <string>
#include <sstream> // std::istringstream
#include <iomanip> // std::get_time
#include <chrono>
#include <fmt/format.h> // fmt::format
#include <fmt/chrono.h> // fmt::format
int main()
{
std::string str = "20010203_040506";
std::tm timeDate = {};
std::istringstream ss(str);
ss >> std::get_time(&timeDate, "%Y%m%d_%H%M%S");
auto _time = std::chrono::system_clock::from_time_t(mktime(&timeDate));
fmt::print("{:%Y-%m-%d %H:%M:%S}\n", std::chrono::floor<std::chrono::seconds>(_time));
}
na moim komputerze jest wynik 2001-02-03 03:05:06
, na godbolt 2001-02-03 04:05:06
jak to poprawić aby u mnie był wynik poprawny czyli taki sam jak godbolt
Gdzie następuje korekta o strefe czasową ?
Jaki w C++ jest najlepszy typ danych do przechowywania DateTime z precyzja 1s ?