[core] move from microsecond precision timestamp to integer second precision

This commit is contained in:
Konstantin Käfer
2016-05-13 15:41:22 +02:00
parent c1dde52c73
commit cd65a43855
26 changed files with 123 additions and 93 deletions

View File

@@ -218,7 +218,9 @@ void Statement::bindBlob(int offset, const std::vector<uint8_t>& value, bool ret
bindBlob(offset, value.data(), value.size(), retain);
}
template <> void Statement::bind(int offset, std::chrono::system_clock::time_point value) {
template <>
void Statement::bind(
int offset, std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds> value) {
assert(stmt);
check(sqlite3_bind_int64(stmt, offset, std::chrono::system_clock::to_time_t(value)));
}
@@ -231,7 +233,10 @@ template <> void Statement::bind(int offset, optional<std::string> value) {
}
}
template <> void Statement::bind(int offset, optional<std::chrono::system_clock::time_point> value) {
template <>
void Statement::bind(
int offset,
optional<std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds>> value) {
if (!value) {
bind(offset, nullptr);
} else {
@@ -283,9 +288,12 @@ template <> std::vector<uint8_t> Statement::get(int offset) {
return { begin, end };
}
template <> std::chrono::system_clock::time_point Statement::get(int offset) {
template <>
std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds>
Statement::get(int offset) {
assert(stmt);
return std::chrono::system_clock::from_time_t(sqlite3_column_int64(stmt, offset));
return std::chrono::time_point_cast<std::chrono::seconds>(
std::chrono::system_clock::from_time_t(sqlite3_column_int64(stmt, offset)));
}
template <> optional<int64_t> Statement::get(int offset) {
@@ -315,12 +323,15 @@ template <> optional<std::string> Statement::get(int offset) {
}
}
template <> optional<std::chrono::system_clock::time_point> Statement::get(int offset) {
template <>
optional<std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds>>
Statement::get(int offset) {
assert(stmt);
if (sqlite3_column_type(stmt, offset) == SQLITE_NULL) {
return optional<std::chrono::system_clock::time_point>();
return {};
} else {
return get<std::chrono::system_clock::time_point>(offset);
return get<std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds>>(
offset);
}
}