diff --git a/include/sqlpp11/chrono.h b/include/sqlpp11/chrono.h index 537e3731..1ab77523 100644 --- a/include/sqlpp11/chrono.h +++ b/include/sqlpp11/chrono.h @@ -27,7 +27,7 @@ #ifndef SQLPP_CHRONO_H #define SQLPP_CHRONO_H -#include +#include namespace sqlpp { @@ -37,6 +37,13 @@ namespace sqlpp using day_point = std::chrono::time_point; using microsecond_point = std::chrono::time_point; + +#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 } } diff --git a/include/sqlpp11/data_types/time_point/operand.h b/include/sqlpp11/data_types/time_point/operand.h index 3c6ff244..eb82f545 100644 --- a/include/sqlpp11/data_types/time_point/operand.h +++ b/include/sqlpp11/data_types/time_point/operand.h @@ -27,7 +27,6 @@ #ifndef SQLPP_TIME_POINT_OPERAND_H #define SQLPP_TIME_POINT_OPERAND_H -#include #include #include #include @@ -76,7 +75,7 @@ namespace sqlpp 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 ymd = ::date::year_month_day{dp}; context << "TIMESTAMP '" << ymd << ' ' << time << "'"; diff --git a/include/sqlpp11/data_types/time_point/result_field.h b/include/sqlpp11/data_types/time_point/result_field.h index c63ea64d..4310de86 100644 --- a/include/sqlpp11/data_types/time_point/result_field.h +++ b/include/sqlpp11/data_types/time_point/result_field.h @@ -27,6 +27,7 @@ #ifndef SQLPP_TIME_POINT_RESULT_FIELD_H #define SQLPP_TIME_POINT_RESULT_FIELD_H +#include #include #include #include @@ -63,7 +64,7 @@ namespace sqlpp } 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 ymd = ::date::year_month_day{dp}; os << ymd << 'T' << time;