diff --git a/source/datetime.cpp b/source/datetime.cpp index 8b024735..e6e8fa5b 100644 --- a/source/datetime.cpp +++ b/source/datetime.cpp @@ -14,29 +14,28 @@ #if defined(NANA_WINDOWS) #include #endif -#include #include namespace { std::tm localtime() { #if defined(NANA_WINDOWS) && !defined(NANA_MINGW) - time_t t; - ::time(&t); + std::time_t t = std::time(nullptr); std::tm tm; - if(localtime_s(&tm, &t) != 0) - assert(false); + if (localtime_s(&tm, &t) != 0) + throw std::runtime_error("invalid local time"); return tm; #else time_t t = std::time(nullptr); struct tm * tm_addr = std::localtime(&t); - assert(tm_addr); - + if(nullptr == tm_addr) + throw std::runtime_error("invalid local time"); + return *tm_addr; #endif } - + ::nana::date::value to_dateval(const std::tm& t) { return {static_cast(t.tm_year + 1900), static_cast(t.tm_mon + 1), static_cast(t.tm_mday)}; @@ -51,7 +50,7 @@ namespace { namespace nana { - //class date + //class date void date::set(const std::tm& t) { value_ = to_dateval(t); diff --git a/source/gui/place.cpp b/source/gui/place.cpp index b29d98b0..b9acf02e 100644 --- a/source/gui/place.cpp +++ b/source/gui/place.cpp @@ -617,7 +617,7 @@ namespace nana : std::invalid_argument{ what + " from place implementation " }, pos{ pos }, - field { field.empty() ? "unnamed" : field } + field(field.empty() ? "unnamed" : field) {} std::string::size_type pos; std::string field; @@ -3674,18 +3674,18 @@ namespace nana std::string field, std::string::size_type pos) - : std::invalid_argument{ "from widget '" + : std::invalid_argument( "from widget '" + API::window_caption(plc.window_handle()).substr(0,80) + "'; nana::place error " + what + "' in field '" + field + (pos == std::string::npos ? "' " : "' at position " + std::to_string(pos)) - + " in div_text:\n" + plc.div() }, - base_what{ what }, - owner_caption{ API::window_caption(plc.window_handle()).substr(0,80) }, - div_text{ plc.div() }, - field{ field }, - pos{ pos } + + " in div_text:\n" + plc.div() ), + base_what( what ), + owner_caption( API::window_caption(plc.window_handle()).substr(0,80) ), + div_text( plc.div() ), + field( field ), + pos( pos ) {} //end class place diff --git a/source/system/dataexch.cpp b/source/system/dataexch.cpp index 8c25ed5e..b3f4d5d4 100644 --- a/source/system/dataexch.cpp +++ b/source/system/dataexch.cpp @@ -15,7 +15,6 @@ #include #include #include -#include #include #if defined(NANA_WINDOWS) @@ -71,7 +70,6 @@ namespace nana{ namespace system{ bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); HDC hDC = ::GetDC(NULL); if (::GetDIBits(hDC, (HBITMAP)g.pixmap(), 0, 1, NULL, (BITMAPINFO *)&bmi, DIB_RGB_COLORS) == 0) { - assert(false); ::ReleaseDC(NULL, hDC); return false; } @@ -109,7 +107,6 @@ namespace nana{ namespace system{ ::CloseClipboard(); } } - assert(false); ::GlobalFree(h_gmem); return false;