mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-16 04:47:18 +08:00
Choosing the "correct" floor method even with MSVC
This commit is contained in:
parent
91defe2450
commit
c63aac480f
@ -27,7 +27,7 @@
|
|||||||
#ifndef SQLPP_CHRONO_H
|
#ifndef SQLPP_CHRONO_H
|
||||||
#define SQLPP_CHRONO_H
|
#define SQLPP_CHRONO_H
|
||||||
|
|
||||||
#include <chrono>
|
#include <date.h>
|
||||||
|
|
||||||
namespace sqlpp
|
namespace sqlpp
|
||||||
{
|
{
|
||||||
@ -37,6 +37,13 @@ namespace sqlpp
|
|||||||
|
|
||||||
using day_point = std::chrono::time_point<std::chrono::system_clock, days>;
|
using day_point = std::chrono::time_point<std::chrono::system_clock, days>;
|
||||||
using microsecond_point = std::chrono::time_point<std::chrono::system_clock, std::chrono::microseconds>;
|
using microsecond_point = std::chrono::time_point<std::chrono::system_clock, std::chrono::microseconds>;
|
||||||
|
|
||||||
|
#if _MSC_FULL_VER >= 190023918
|
||||||
|
// MSVC Update 2 provides floor, ceil, round, abs in chrono (which is C++17 only...)
|
||||||
|
using ::std::chrono::floor;
|
||||||
|
#else
|
||||||
|
using ::date::floor;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
#ifndef SQLPP_TIME_POINT_OPERAND_H
|
#ifndef SQLPP_TIME_POINT_OPERAND_H
|
||||||
#define SQLPP_TIME_POINT_OPERAND_H
|
#define SQLPP_TIME_POINT_OPERAND_H
|
||||||
|
|
||||||
#include <date.h>
|
|
||||||
#include <sqlpp11/chrono.h>
|
#include <sqlpp11/chrono.h>
|
||||||
#include <sqlpp11/type_traits.h>
|
#include <sqlpp11/type_traits.h>
|
||||||
#include <sqlpp11/alias_operators.h>
|
#include <sqlpp11/alias_operators.h>
|
||||||
@ -76,7 +75,7 @@ namespace sqlpp
|
|||||||
|
|
||||||
static Context& _(const Operand& t, Context& context)
|
static Context& _(const Operand& t, Context& context)
|
||||||
{
|
{
|
||||||
const auto dp = ::date::floor<::date::days>(t._t);
|
const auto dp = ::sqlpp::chrono::floor<::date::days>(t._t);
|
||||||
const auto time = ::date::make_time(t._t - dp);
|
const auto time = ::date::make_time(t._t - dp);
|
||||||
const auto ymd = ::date::year_month_day{dp};
|
const auto ymd = ::date::year_month_day{dp};
|
||||||
context << "TIMESTAMP '" << ymd << ' ' << time << "'";
|
context << "TIMESTAMP '" << ymd << ' ' << time << "'";
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#ifndef SQLPP_TIME_POINT_RESULT_FIELD_H
|
#ifndef SQLPP_TIME_POINT_RESULT_FIELD_H
|
||||||
#define SQLPP_TIME_POINT_RESULT_FIELD_H
|
#define SQLPP_TIME_POINT_RESULT_FIELD_H
|
||||||
|
|
||||||
|
#include <sqlpp11/chrono.h>
|
||||||
#include <sqlpp11/basic_expression_operators.h>
|
#include <sqlpp11/basic_expression_operators.h>
|
||||||
#include <sqlpp11/result_field.h>
|
#include <sqlpp11/result_field.h>
|
||||||
#include <sqlpp11/result_field_base.h>
|
#include <sqlpp11/result_field_base.h>
|
||||||
@ -63,7 +64,7 @@ namespace sqlpp
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const auto dp = ::date::floor<::date::days>(e.value());
|
const auto dp = ::sqlpp::chrono::floor<::date::days>(e.value());
|
||||||
const auto time = ::date::make_time(e.value() - dp);
|
const auto time = ::date::make_time(e.value() - dp);
|
||||||
const auto ymd = ::date::year_month_day{dp};
|
const auto ymd = ::date::year_month_day{dp};
|
||||||
os << ymd << 'T' << time;
|
os << ymd << 'T' << time;
|
||||||
|
Loading…
Reference in New Issue
Block a user