Fix for reading epoch due to scnlib format changes (#3166)

This commit is contained in:
Gene Payne
2024-04-18 21:54:38 -06:00
committed by GitHub
parent 4476184746
commit e5306a7b59

View File

@@ -266,15 +266,20 @@ namespace {
epoch.end(),
[](char c) { return c == '-'; }
);
const std::string format = (nDashes == 2) ? "{:4}-{:2}-{:2}{}" : "{:4}{:2}{:2}{}";
auto res = scn::scan<int, int, int, double>(e, scn::runtime_format(format));
const std::string format = (nDashes == 2) ? "{:4d}-{:2d}-{}" : "{:4d}{:2d}{}";
auto res = scn::scan<int, int, double>(e, scn::runtime_format(format));
if (!res) {
throw ghoul::RuntimeError(std::format("Error parsing epoch '{}'", epoch));
}
auto [year, monthNum, dayOfMonthNum, fractionOfDay] = res->values();
auto [year, monthNum, dayOfMonth] = res->values();
const int daysSince2000 = countDays(year);
const int wholeDaysInto = daysIntoGivenYear(year, monthNum, dayOfMonthNum);
const double daysInYear = static_cast<double>(wholeDaysInto) + fractionOfDay;
const int daysInto = daysIntoGivenYear(
year,
monthNum,
static_cast<int>(dayOfMonth)
);
const double daysInYear = static_cast<double>(daysInto) +
(dayOfMonth - std::floor(dayOfMonth));
// 3
using namespace std::chrono;