datetime.ipp 904 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. //
  2. // Copyright (c) 2019-2024 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. #ifndef BOOST_MYSQL_IMPL_DATETIME_IPP
  8. #define BOOST_MYSQL_IMPL_DATETIME_IPP
  9. #pragma once
  10. #include <boost/mysql/datetime.hpp>
  11. #include <boost/mysql/string_view.hpp>
  12. #include <boost/mysql/impl/internal/dt_to_string.hpp>
  13. #include <cstddef>
  14. #include <ostream>
  15. std::ostream& boost::mysql::operator<<(std::ostream& os, const datetime& value)
  16. {
  17. char buffer[64]{};
  18. std::size_t sz = detail::datetime_to_string(
  19. value.year(),
  20. value.month(),
  21. value.day(),
  22. value.hour(),
  23. value.minute(),
  24. value.second(),
  25. value.microsecond(),
  26. buffer
  27. );
  28. os << string_view(buffer, sz);
  29. return os;
  30. }
  31. #endif