From 5e7fbe177da1f55635e533757f4d43d56e6ba7dc Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Fri, 9 Jun 2017 07:57:27 -0500 Subject: [PATCH] Always format month/day/hour/second/minute placeholder variables out to their full width. Fixes #4019 --- xs/src/libslic3r/PlaceholderParser.cpp | 44 +++++++++++++++++++------- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/xs/src/libslic3r/PlaceholderParser.cpp b/xs/src/libslic3r/PlaceholderParser.cpp index 501349d5c..675bd1fad 100644 --- a/xs/src/libslic3r/PlaceholderParser.cpp +++ b/xs/src/libslic3r/PlaceholderParser.cpp @@ -36,24 +36,44 @@ PlaceholderParser::update_timestamp() time_t rawtime; time(&rawtime); struct tm* timeinfo = localtime(&rawtime); - + + this->set("year", 1900 + timeinfo->tm_year); + { + std::ostringstream ss; + ss << std::setw(2) << std::setfill('0') << (1 + timeinfo->tm_mon); + this->set("month", ss.str()); + } + { + std::ostringstream ss; + ss << std::setw(2) << std::setfill('0') << timeinfo->tm_mday; + this->set("day", ss.str()); + } + { + std::ostringstream ss; + ss << std::setw(2) << std::setfill('0') << timeinfo->tm_hour; + this->set("hour", ss.str()); + } + { + std::ostringstream ss; + ss << std::setw(2) << std::setfill('0') << timeinfo->tm_min; + this->set("minute", ss.str()); + } + { + std::ostringstream ss; + ss << std::setw(2) << std::setfill('0') << timeinfo->tm_sec; + this->set("second", ss.str()); + } { std::ostringstream ss; ss << (1900 + timeinfo->tm_year); - ss << std::setw(2) << std::setfill('0') << (1 + timeinfo->tm_mon); - ss << std::setw(2) << std::setfill('0') << timeinfo->tm_mday; + ss << this->_single["month"]; + ss << this->_single["day"]; ss << "-"; - ss << std::setw(2) << std::setfill('0') << timeinfo->tm_hour; - ss << std::setw(2) << std::setfill('0') << timeinfo->tm_min; - ss << std::setw(2) << std::setfill('0') << timeinfo->tm_sec; + ss << this->_single["hour"]; + ss << this->_single["minute"]; + ss << this->_single["second"]; this->set("timestamp", ss.str()); } - this->set("year", 1900 + timeinfo->tm_year); - this->set("month", 1 + timeinfo->tm_mon); - this->set("day", timeinfo->tm_mday); - this->set("hour", timeinfo->tm_hour); - this->set("minute", timeinfo->tm_min); - this->set("second", timeinfo->tm_sec); } void PlaceholderParser::apply_config(const DynamicPrintConfig &config)