diff options
author | bubnikv <bubnikv@gmail.com> | 2019-09-12 11:19:09 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2019-09-12 11:19:09 +0300 |
commit | b4f2df6a98369b0de813c237c564c4cffbedf4ea (patch) | |
tree | 1279340beec33e39adb05ae3020a25d7126ded04 /src/slic3r | |
parent | 22ab0220889ca72dc82b478be3e0c62bca4cfba6 (diff) | |
parent | 6f4fff1b29476e70a327f8c0c2ca2e16dc6b6a34 (diff) |
Merge remote-tracking branch 'remotes/origin/master' into dev
Diffstat (limited to 'src/slic3r')
-rw-r--r-- | src/slic3r/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/slic3r/Config/Snapshot.cpp | 2 | ||||
-rw-r--r-- | src/slic3r/GUI/ConfigSnapshotDialog.cpp | 2 | ||||
-rw-r--r-- | src/slic3r/GUI/Plater.cpp | 3 | ||||
-rw-r--r-- | src/slic3r/Utils/Time.cpp | 86 | ||||
-rw-r--r-- | src/slic3r/Utils/Time.hpp | 25 |
6 files changed, 4 insertions, 116 deletions
diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index e51415d53..161e1a1ff 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -148,8 +148,6 @@ set(SLIC3R_GUI_SOURCES Utils/Bonjour.hpp Utils/PresetUpdater.cpp Utils/PresetUpdater.hpp - Utils/Time.cpp - Utils/Time.hpp Utils/UndoRedo.cpp Utils/UndoRedo.hpp Utils/HexFile.cpp diff --git a/src/slic3r/Config/Snapshot.cpp b/src/slic3r/Config/Snapshot.cpp index 2aebd0c72..622b31a17 100644 --- a/src/slic3r/Config/Snapshot.cpp +++ b/src/slic3r/Config/Snapshot.cpp @@ -1,7 +1,6 @@ #include "Snapshot.hpp" #include "../GUI/AppConfig.hpp" #include "../GUI/PresetBundle.hpp" -#include "../Utils/Time.hpp" #include <time.h> @@ -13,6 +12,7 @@ #include <boost/property_tree/ptree.hpp> #include "libslic3r/libslic3r.h" +#include "libslic3r/Time.hpp" #include "libslic3r/Config.hpp" #include "libslic3r/FileParserError.hpp" #include "libslic3r/Utils.hpp" diff --git a/src/slic3r/GUI/ConfigSnapshotDialog.cpp b/src/slic3r/GUI/ConfigSnapshotDialog.cpp index 59ed38412..836a0a4d3 100644 --- a/src/slic3r/GUI/ConfigSnapshotDialog.cpp +++ b/src/slic3r/GUI/ConfigSnapshotDialog.cpp @@ -2,9 +2,9 @@ #include "I18N.hpp" #include "../Config/Snapshot.hpp" -#include "../Utils/Time.hpp" #include "libslic3r/Utils.hpp" +#include "libslic3r/Time.hpp" #include "GUI_App.hpp" #include "wxExtensions.hpp" diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 803510f80..3075d11ed 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1135,7 +1135,8 @@ void Sidebar::show_sliced_info_sizer(const bool show) p->sliced_info->SetTextAndShow(siMateril_unit, info_text, new_label); p->sliced_info->SetTextAndShow(siCost, "N/A"/*wxString::Format("%.2f", ps.total_cost)*/); - p->sliced_info->SetTextAndShow(siEstimatedTime, ps.estimated_print_time, _(L("Estimated printing time")) + " :"); + wxString t_est = std::isnan(ps.estimated_print_time) ? "N/A" : get_time_dhms(float(ps.estimated_print_time)); + p->sliced_info->SetTextAndShow(siEstimatedTime, t_est, _(L("Estimated printing time")) + " :"); // Hide non-SLA sliced info parameters p->sliced_info->SetTextAndShow(siFilament_m, "N/A"); diff --git a/src/slic3r/Utils/Time.cpp b/src/slic3r/Utils/Time.cpp deleted file mode 100644 index db1aa31f6..000000000 --- a/src/slic3r/Utils/Time.cpp +++ /dev/null @@ -1,86 +0,0 @@ -#include "Time.hpp" - -#ifdef WIN32 - #define WIN32_LEAN_AND_MEAN - #include <windows.h> - #undef WIN32_LEAN_AND_MEAN -#endif /* WIN32 */ - -namespace Slic3r { -namespace Utils { - -time_t parse_time_ISO8601Z(const std::string &sdate) -{ - int y, M, d, h, m, s; - if (sscanf(sdate.c_str(), "%04d%02d%02dT%02d%02d%02dZ", &y, &M, &d, &h, &m, &s) != 6) - return (time_t)-1; - struct tm tms; - tms.tm_year = y - 1900; // Year since 1900 - tms.tm_mon = M - 1; // 0-11 - tms.tm_mday = d; // 1-31 - tms.tm_hour = h; // 0-23 - tms.tm_min = m; // 0-59 - tms.tm_sec = s; // 0-61 (0-60 in C++11) -#ifdef WIN32 - return _mkgmtime(&tms); -#else /* WIN32 */ - return timegm(&tms); -#endif /* WIN32 */ -} - -std::string format_time_ISO8601Z(time_t time) -{ - struct tm tms; -#ifdef WIN32 - gmtime_s(&tms, &time); -#else - gmtime_r(&time, &tms); -#endif - char buf[128]; - sprintf(buf, "%04d%02d%02dT%02d%02d%02dZ", - tms.tm_year + 1900, - tms.tm_mon + 1, - tms.tm_mday, - tms.tm_hour, - tms.tm_min, - tms.tm_sec); - return buf; -} - -std::string format_local_date_time(time_t time) -{ - struct tm tms; -#ifdef WIN32 - // Converts a time_t time value to a tm structure, and corrects for the local time zone. - localtime_s(&tms, &time); -#else - localtime_r(&time, &tms); -#endif - char buf[80]; - strftime(buf, 80, "%x %X", &tms); - return buf; -} - -time_t get_current_time_utc() -{ -#ifdef WIN32 - SYSTEMTIME st; - // Retrieves the current system date and time. The system time is expressed in Coordinated Universal Time (UTC). - ::GetSystemTime(&st); - std::tm tm; - tm.tm_sec = st.wSecond; - tm.tm_min = st.wMinute; - tm.tm_hour = st.wHour; - tm.tm_mday = st.wDay; - tm.tm_mon = st.wMonth - 1; - tm.tm_year = st.wYear - 1900; - tm.tm_isdst = -1; - return _mkgmtime(&tm); -#else - // time() returns the time as the number of seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC). - return time(nullptr); -#endif -} - -}; // namespace Utils -}; // namespace Slic3r diff --git a/src/slic3r/Utils/Time.hpp b/src/slic3r/Utils/Time.hpp deleted file mode 100644 index 6a1aefa18..000000000 --- a/src/slic3r/Utils/Time.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef slic3r_Utils_Time_hpp_ -#define slic3r_Utils_Time_hpp_ - -#include <string> -#include <ctime> - -namespace Slic3r { -namespace Utils { - -// Utilities to convert an UTC time_t to/from an ISO8601 time format, -// useful for putting timestamps into file and directory names. -// Returns (time_t)-1 on error. -extern time_t parse_time_ISO8601Z(const std::string &s); -extern std::string format_time_ISO8601Z(time_t time); - -// Format the date and time from an UTC time according to the active locales and a local time zone. -extern std::string format_local_date_time(time_t time); - -// There is no gmtime() on windows. -extern time_t get_current_time_utc(); - -}; // namespace Utils -}; // namespace Slic3r - -#endif /* slic3r_Utils_Time_hpp_ */ |