diff --git a/libs/indibase/indiccd.cpp b/libs/indibase/indiccd.cpp index bdfa1dc0ae..c39ca4a60b 100644 --- a/libs/indibase/indiccd.cpp +++ b/libs/indibase/indiccd.cpp @@ -47,6 +47,7 @@ #include #include +#include #include #include #include @@ -2543,14 +2544,18 @@ bool CCD::uploadFile(CCDChip * targetChip, const void * fitsData, size_t totalBy if (maxIndex > 0) { - char ts[32]; - struct tm * tp; - time_t t; - time(&t); - tp = localtime(&t); - strftime(ts, sizeof(ts), "%Y-%m-%dT%H-%M-%S", tp); - std::string filets(ts); - prefix = std::regex_replace(prefix, std::regex("ISO8601"), filets); + auto now = std::chrono::system_clock::now(); + std::time_t time = std::chrono::system_clock::to_time_t(now); + std::tm* now_tm = std::localtime(&time); + long long timestamp = std::chrono::duration_cast(now.time_since_epoch()).count(); + + std::stringstream stream; + stream << std::setfill('0') + << std::put_time(now_tm, "%FT%H:%M:") + << std::setw(2) << (timestamp / 1000) % 60 << '.' + << std::setw(3) << timestamp % 1000; + + prefix = std::regex_replace(prefix, std::regex("ISO8601"), stream.str()); char indexString[8]; snprintf(indexString, 8, "%03d", maxIndex);