time.hxx
#ifndef PQXX_H_TIME
#define PQXX_H_TIME
#if !defined(PQXX_HEADER_PRE)
# error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
#endif
#include <chrono>
#include <cstdlib>
#include "pqxx/internal/concat.hxx"
#include "pqxx/strconv.hxx"
#if defined(PQXX_HAVE_YEAR_MONTH_DAY)
namespace pqxx
{
using namespace std::literals;
template<>
struct nullness<std::chrono::year_month_day>
: no_null<std::chrono::year_month_day>
{};
template<> struct PQXX_LIBEXPORT string_traits<std::chrono::year_month_day>
{
[[nodiscard]] static zview
to_buf(char *begin, char *end, std::chrono::year_month_day const &value)
{
return generic_to_buf(begin, end, value);
}
static char *
into_buf(char *begin, char *end, std::chrono::year_month_day const &value);
[[nodiscard]] static std::chrono::year_month_day
from_string(std::string_view text);
[[nodiscard]] static std::size_t
size_buffer(std::chrono::year_month_day const &) noexcept
{
static_assert(int{(std::chrono::year::min)()} >= -99999);
static_assert(int{(std::chrono::year::max)()} <= 99999);
return 5 + 1 + 2 + 1 + 2 + std::size(s_bc) + 1;
}
private:
static constexpr std::string_view s_bc{" BC"sv};
};
} // namespace pqxx
#endif // PQXX_HAVE_YEAR_MONTH_DAY
#endif
pqxx
The home of all libpqxx classes, functions, templates, etc.
Definition array.hxx:33
pqxx::from_string
T from_string(field const &value)
Convert a field's value to type T.
Definition field.hxx:520
pqxx::format::text
@ text