Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:42:42

0001 //
0002 // Copyright (c) 2019-2023 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
0003 //
0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 
0008 #ifndef BOOST_MYSQL_IMPL_DATETIME_IPP
0009 #define BOOST_MYSQL_IMPL_DATETIME_IPP
0010 
0011 #pragma once
0012 
0013 #include <boost/mysql/datetime.hpp>
0014 
0015 #include <cstdio>
0016 #include <ostream>
0017 
0018 std::ostream& boost::mysql::operator<<(std::ostream& os, const datetime& value)
0019 {
0020     // Worst-case output is 37 chars, extra space just in case
0021     char buffer[64]{};
0022     snprintf(
0023         buffer,
0024         sizeof(buffer),
0025         "%04u-%02u-%02u %02d:%02u:%02u.%06u",
0026         static_cast<unsigned>(value.year()),
0027         static_cast<unsigned>(value.month()),
0028         static_cast<unsigned>(value.day()),
0029         static_cast<unsigned>(value.hour()),
0030         static_cast<unsigned>(value.minute()),
0031         static_cast<unsigned>(value.second()),
0032         static_cast<unsigned>(value.microsecond())
0033     );
0034     os << buffer;
0035     return os;
0036 }
0037 
0038 #endif