// // Copyright (c) 2019-2023 Ruben Perez Hidalgo (rubenperez038 at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #ifndef BHO_MYSQL_IMPL_DATETIME_IPP #define BHO_MYSQL_IMPL_DATETIME_IPP #pragma once #include #include #include std::ostream& bho::mysql::operator<<(std::ostream& os, const datetime& value) { // Worst-case output is 37 chars, extra space just in case char buffer[64]{}; snprintf( buffer, sizeof(buffer), "%04u-%02u-%02u %02d:%02u:%02u.%06u", static_cast(value.year()), static_cast(value.month()), static_cast(value.day()), static_cast(value.hour()), static_cast(value.minute()), static_cast(value.second()), static_cast(value.microsecond()) ); os << buffer; return os; } #endif