datetime.hpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //
  2. // Copyright (c) 2019-2023 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_DETAIL_AUXILIAR_DATETIME_HPP
  8. #define BOOST_MYSQL_DETAIL_AUXILIAR_DATETIME_HPP
  9. // All these algorithms have been taken from:
  10. // http://howardhinnant.github.io/date_algorithms.html
  11. #include <boost/config.hpp>
  12. #include <cstdint>
  13. namespace boost {
  14. namespace mysql {
  15. namespace detail {
  16. constexpr inline bool is_valid(std::uint16_t years, std::uint8_t month, std::uint8_t day) noexcept;
  17. BOOST_CXX14_CONSTEXPR inline int ymd_to_days(
  18. std::uint16_t years,
  19. std::uint8_t month,
  20. std::uint8_t day
  21. ) noexcept;
  22. BOOST_CXX14_CONSTEXPR inline bool days_to_ymd(
  23. int num_days,
  24. std::uint16_t& years,
  25. std::uint8_t& month,
  26. std::uint8_t& day
  27. ) noexcept;
  28. constexpr std::uint16_t max_year = 9999;
  29. constexpr std::uint8_t max_month = 12;
  30. constexpr std::uint8_t max_day = 31;
  31. constexpr std::uint8_t max_hour = 23;
  32. constexpr std::uint8_t max_min = 59;
  33. constexpr std::uint8_t max_sec = 59;
  34. constexpr std::uint32_t max_micro = 999999;
  35. } // namespace detail
  36. } // namespace mysql
  37. } // namespace boost
  38. #include <boost/mysql/detail/auxiliar/impl/datetime.hpp>
  39. #endif