improve compatability with old compiler
This commit is contained in:
parent
80b3566e9b
commit
363953be20
@ -14,29 +14,28 @@
|
|||||||
#if defined(NANA_WINDOWS)
|
#if defined(NANA_WINDOWS)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
#include <cassert>
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
std::tm localtime()
|
std::tm localtime()
|
||||||
{
|
{
|
||||||
#if defined(NANA_WINDOWS) && !defined(NANA_MINGW)
|
#if defined(NANA_WINDOWS) && !defined(NANA_MINGW)
|
||||||
time_t t;
|
std::time_t t = std::time(nullptr);
|
||||||
::time(&t);
|
|
||||||
std::tm tm;
|
std::tm tm;
|
||||||
if(localtime_s(&tm, &t) != 0)
|
if (localtime_s(&tm, &t) != 0)
|
||||||
assert(false);
|
throw std::runtime_error("invalid local time");
|
||||||
|
|
||||||
return tm;
|
return tm;
|
||||||
#else
|
#else
|
||||||
time_t t = std::time(nullptr);
|
time_t t = std::time(nullptr);
|
||||||
struct tm * tm_addr = std::localtime(&t);
|
struct tm * tm_addr = std::localtime(&t);
|
||||||
assert(tm_addr);
|
if(nullptr == tm_addr)
|
||||||
|
throw std::runtime_error("invalid local time");
|
||||||
|
|
||||||
return *tm_addr;
|
return *tm_addr;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
::nana::date::value to_dateval(const std::tm& t)
|
::nana::date::value to_dateval(const std::tm& t)
|
||||||
{
|
{
|
||||||
return {static_cast<unsigned>(t.tm_year + 1900), static_cast<unsigned>(t.tm_mon + 1), static_cast<unsigned>(t.tm_mday)};
|
return {static_cast<unsigned>(t.tm_year + 1900), static_cast<unsigned>(t.tm_mon + 1), static_cast<unsigned>(t.tm_mday)};
|
||||||
@ -51,7 +50,7 @@ namespace {
|
|||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
//class date
|
//class date
|
||||||
void date::set(const std::tm& t)
|
void date::set(const std::tm& t)
|
||||||
{
|
{
|
||||||
value_ = to_dateval(t);
|
value_ = to_dateval(t);
|
||||||
|
@ -617,7 +617,7 @@ namespace nana
|
|||||||
|
|
||||||
: std::invalid_argument{ what + " from place implementation " },
|
: std::invalid_argument{ what + " from place implementation " },
|
||||||
pos{ pos },
|
pos{ pos },
|
||||||
field { field.empty() ? "unnamed" : field }
|
field(field.empty() ? "unnamed" : field)
|
||||||
{}
|
{}
|
||||||
std::string::size_type pos;
|
std::string::size_type pos;
|
||||||
std::string field;
|
std::string field;
|
||||||
@ -3674,18 +3674,18 @@ namespace nana
|
|||||||
std::string field,
|
std::string field,
|
||||||
std::string::size_type pos)
|
std::string::size_type pos)
|
||||||
|
|
||||||
: std::invalid_argument{ "from widget '"
|
: std::invalid_argument( "from widget '"
|
||||||
+ API::window_caption(plc.window_handle()).substr(0,80)
|
+ API::window_caption(plc.window_handle()).substr(0,80)
|
||||||
+ "'; nana::place error "
|
+ "'; nana::place error "
|
||||||
+ what
|
+ what
|
||||||
+ "' in field '" + field
|
+ "' in field '" + field
|
||||||
+ (pos == std::string::npos ? "' " : "' at position " + std::to_string(pos))
|
+ (pos == std::string::npos ? "' " : "' at position " + std::to_string(pos))
|
||||||
+ " in div_text:\n" + plc.div() },
|
+ " in div_text:\n" + plc.div() ),
|
||||||
base_what{ what },
|
base_what( what ),
|
||||||
owner_caption{ API::window_caption(plc.window_handle()).substr(0,80) },
|
owner_caption( API::window_caption(plc.window_handle()).substr(0,80) ),
|
||||||
div_text{ plc.div() },
|
div_text( plc.div() ),
|
||||||
field{ field },
|
field( field ),
|
||||||
pos{ pos }
|
pos( pos )
|
||||||
{}
|
{}
|
||||||
//end class place
|
//end class place
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
#include <nana/paint/graphics.hpp>
|
#include <nana/paint/graphics.hpp>
|
||||||
#include <nana/paint/pixel_buffer.hpp>
|
#include <nana/paint/pixel_buffer.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cassert>
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#if defined(NANA_WINDOWS)
|
#if defined(NANA_WINDOWS)
|
||||||
@ -71,7 +70,6 @@ namespace nana{ namespace system{
|
|||||||
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
HDC hDC = ::GetDC(NULL);
|
HDC hDC = ::GetDC(NULL);
|
||||||
if (::GetDIBits(hDC, (HBITMAP)g.pixmap(), 0, 1, NULL, (BITMAPINFO *)&bmi, DIB_RGB_COLORS) == 0) {
|
if (::GetDIBits(hDC, (HBITMAP)g.pixmap(), 0, 1, NULL, (BITMAPINFO *)&bmi, DIB_RGB_COLORS) == 0) {
|
||||||
assert(false);
|
|
||||||
::ReleaseDC(NULL, hDC);
|
::ReleaseDC(NULL, hDC);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -109,7 +107,6 @@ namespace nana{ namespace system{
|
|||||||
::CloseClipboard();
|
::CloseClipboard();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert(false);
|
|
||||||
::GlobalFree(h_gmem);
|
::GlobalFree(h_gmem);
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user