mirror of
https://github.com/rbock/sqlpp11.git
synced 2026-02-18 04:08:47 -06:00
Merge branch 'feature/msvc-again-04' into develop
This commit is contained in:
@@ -15,9 +15,6 @@ build_script:
|
||||
- cd ..
|
||||
- CD
|
||||
- git clone https://github.com/HowardHinnant/date
|
||||
- cd date
|
||||
- git checkout tags/v1.0.0
|
||||
- cd ..
|
||||
- cd sqlpp11
|
||||
- CD
|
||||
- echo %configuration%
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#ifndef SQLPP_CHRONO_H
|
||||
#define SQLPP_CHRONO_H
|
||||
|
||||
#include <chrono>
|
||||
#include <date.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
@@ -37,6 +37,13 @@ namespace sqlpp
|
||||
|
||||
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>;
|
||||
|
||||
#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
|
||||
#define SQLPP_TIME_POINT_OPERAND_H
|
||||
|
||||
#include <date.h>
|
||||
#include <sqlpp11/chrono.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/alias_operators.h>
|
||||
@@ -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 << "'";
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#ifndef 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/result_field.h>
|
||||
#include <sqlpp11/result_field_base.h>
|
||||
@@ -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;
|
||||
|
||||
@@ -30,6 +30,13 @@
|
||||
|
||||
SQLPP_ALIAS_PROVIDER(now)
|
||||
|
||||
#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
|
||||
|
||||
int DateTime(int, char* [])
|
||||
{
|
||||
MockDb db = {};
|
||||
@@ -48,23 +55,23 @@ int DateTime(int, char* [])
|
||||
printer.reset();
|
||||
std::cerr << serialize(::sqlpp::value(std::chrono::system_clock::now()), printer).str() << std::endl;
|
||||
|
||||
db(insert_into(t).set(t.colDayPoint = ::date::floor<::sqlpp::chrono::days>(std::chrono::system_clock::now())));
|
||||
db(insert_into(t).set(t.colTimePoint = ::date::floor<::sqlpp::chrono::days>(std::chrono::system_clock::now())));
|
||||
db(insert_into(t).set(t.colDayPoint = floor<::sqlpp::chrono::days>(std::chrono::system_clock::now())));
|
||||
db(insert_into(t).set(t.colTimePoint = floor<::sqlpp::chrono::days>(std::chrono::system_clock::now())));
|
||||
db(insert_into(t).set(t.colTimePoint = std::chrono::system_clock::now()));
|
||||
|
||||
db(update(t)
|
||||
.set(t.colDayPoint = ::date::floor<::sqlpp::chrono::days>(std::chrono::system_clock::now()))
|
||||
.set(t.colDayPoint = floor<::sqlpp::chrono::days>(std::chrono::system_clock::now()))
|
||||
.where(t.colDayPoint < std::chrono::system_clock::now()));
|
||||
db(update(t)
|
||||
.set(t.colTimePoint = ::date::floor<::sqlpp::chrono::days>(std::chrono::system_clock::now()))
|
||||
.set(t.colTimePoint = floor<::sqlpp::chrono::days>(std::chrono::system_clock::now()))
|
||||
.where(t.colDayPoint < std::chrono::system_clock::now()));
|
||||
db(update(t)
|
||||
.set(t.colTimePoint = std::chrono::system_clock::now())
|
||||
.where(t.colDayPoint < std::chrono::system_clock::now()));
|
||||
|
||||
db(remove_from(t).where(t.colDayPoint == ::date::floor<::sqlpp::chrono::days>(std::chrono::system_clock::now())));
|
||||
db(remove_from(t).where(t.colDayPoint == floor<::sqlpp::chrono::days>(std::chrono::system_clock::now())));
|
||||
db(remove_from(t).where(t.colDayPoint == std::chrono::system_clock::now()));
|
||||
db(remove_from(t).where(t.colTimePoint == ::date::floor<::sqlpp::chrono::days>(std::chrono::system_clock::now())));
|
||||
db(remove_from(t).where(t.colTimePoint == floor<::sqlpp::chrono::days>(std::chrono::system_clock::now())));
|
||||
db(remove_from(t).where(t.colTimePoint == std::chrono::system_clock::now()));
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user