Directly create the correct date/time format

This commit is contained in:
Alexander Bock
2020-08-13 11:42:12 +02:00
parent 38eac377e8
commit 760c34660f
2 changed files with 9 additions and 28 deletions
+4 -21
View File
@@ -86,27 +86,10 @@ std::string Time::UTC() const {
std::string Time::ISO8601() const {
ZoneScoped
std::string datetime = SpiceManager::ref().dateFromEphemerisTime(_time);
std::string_view month = std::string_view(datetime).substr(5, 3);
std::string_view mm = [](std::string_view month) {
if (month == "JAN") { return "-01-"; }
else if (month == "FEB") { return "-02-"; }
else if (month == "MAR") { return "-03-"; }
else if (month == "APR") { return "-04-"; }
else if (month == "MAY") { return "-05-"; }
else if (month == "JUN") { return "-06-"; }
else if (month == "JUL") { return "-07-"; }
else if (month == "AUG") { return "-08-"; }
else if (month == "SEP") { return "-09-"; }
else if (month == "OCT") { return "-10-"; }
else if (month == "NOV") { return "-11-"; }
else if (month == "DEC") { return "-12-"; }
else { throw ghoul::MissingCaseException(); }
}(month);
datetime.replace(4, 5, mm);
return datetime;
return SpiceManager::ref().dateFromEphemerisTime(
_time,
"YYYY-MM-DDTHR:MN:SC.###"
);
}
scripting::LuaLibrary Time::luaLibrary() {