File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Copyright 2018, 2019 Peter Dimov
2+ # Distributed under the Boost Software License, Version 1.0.
3+ # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
4+
5+ cmake_minimum_required (VERSION 3.5...3.31 )
6+
7+ if (POLICY CMP0074)
8+ cmake_policy (SET CMP0074 NEW )
9+ endif ()
10+
11+ project (CmakeConfigDateTimeTest LANGUAGES CXX )
12+
13+ include (${CMAKE_CURRENT_LIST_DIR } /../BoostVersion.cmake )
14+
15+ set (BOOST_HINTS)
16+
17+ if (USE_STAGED_BOOST)
18+ set (BOOST_HINTS HINTS ../../../../stage)
19+ endif ()
20+
21+ find_package (Boost ${BOOST_VERSION} EXACT REQUIRED COMPONENTS date_time ${BOOST_HINTS} )
22+
23+ add_executable (main quick.cpp )
24+ target_link_libraries (main Boost::date_time Boost::headers )
25+
26+ enable_testing ()
27+ add_custom_target (check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND } --output-on-failure --no-tests=error -C $<CONFIG >)
28+
29+ add_test (main main )
Original file line number Diff line number Diff line change 1+ // Copyright 2026 Peter Dimov
2+ // Distributed under the Boost Software License, Version 1.0.
3+ // https://www.boost.org/LICENSE_1_0.txt
4+
5+ #include < boost/date_time.hpp>
6+ #include < boost/core/lightweight_test.hpp>
7+ #include < iostream>
8+
9+ int main ()
10+ {
11+ using namespace boost ::gregorian;
12+ using namespace boost ::posix_time;
13+
14+ date d ( 2026 , Apr, 27 );
15+ ptime t ( d, hours (20 ) + minutes (26 ) + seconds (11 ) );
16+
17+ std::cout << t << std::endl;
18+
19+ BOOST_TEST_EQ ( t.date ().day (), 27 );
20+ BOOST_TEST_EQ ( t.date ().month (), Apr );
21+ BOOST_TEST_EQ ( t.date ().year (), 2026 );
22+
23+ BOOST_TEST_EQ ( t.time_of_day ().hours (), 20 );
24+ BOOST_TEST_EQ ( t.time_of_day ().minutes (), 26 );
25+ BOOST_TEST_EQ ( t.time_of_day ().seconds (), 11 );
26+
27+ return boost::report_errors ();
28+ }
You can’t perform that action at this time.
0 commit comments