From 50b3550f1035121b00e943c9d4cbd0751d1615b9 Mon Sep 17 00:00:00 2001 From: toge Date: Fri, 10 May 2024 20:41:31 +0900 Subject: [PATCH 1/4] date: support gcc14 on test_package --- recipes/date/all/conanfile.py | 4 ++-- recipes/date/all/test_package/test_package.cpp | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/recipes/date/all/conanfile.py b/recipes/date/all/conanfile.py index 315ca73f8ae1f..1c20c0f8daac1 100644 --- a/recipes/date/all/conanfile.py +++ b/recipes/date/all/conanfile.py @@ -11,11 +11,11 @@ class DateConan(ConanFile): name = "date" + description = "A date and time library based on the C++11/14/17 header" + license = "MIT" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/HowardHinnant/date" - description = "A date and time library based on the C++11/14/17 header" topics = ("datetime", "timezone", "calendar", "time", "iana-database") - license = "MIT" package_type = "library" settings = "os", "arch", "compiler", "build_type" options = { diff --git a/recipes/date/all/test_package/test_package.cpp b/recipes/date/all/test_package/test_package.cpp index 8dcac9f656989..a636960b5c6aa 100644 --- a/recipes/date/all/test_package/test_package.cpp +++ b/recipes/date/all/test_package/test_package.cpp @@ -16,7 +16,7 @@ class ZoneOffset { -> date::local_time::type> { using namespace date; using namespace std::chrono; - using LT = local_time::type>; + using LT = date::local_time::type>; return LT{(tp + _offset).time_since_epoch()}; } @@ -25,7 +25,7 @@ class ZoneOffset { -> date::sys_time::type> { using namespace date; using namespace std::chrono; - using ST = sys_time::type>; + using ST = date::sys_time::type>; return ST{(tp - _offset).time_since_epoch()}; } @@ -34,7 +34,9 @@ class ZoneOffset { }; int main() { - using namespace std::chrono; + using std::chrono::hours; + using std::chrono::milliseconds; + using std::chrono::minutes; using namespace date; auto date1 = 2015_y/March/22; @@ -45,7 +47,7 @@ int main() { std::cout << date3 << '\n'; ZoneOffset p3_45{hours{3} + minutes{45}}; - zoned_time zt{&p3_45, floor(system_clock::now())}; + zoned_time zt{&p3_45, floor(std::chrono::system_clock::now())}; std::cout << zt.get_sys_time() << " (sys time)\n"; std::cout << zt.get_local_time() << " (local time)\n"; From 9a8c80d366a9da45c21424142e6f9f2b5eb7f822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abril=20Rinc=C3=B3n=20Blanco?= Date: Mon, 4 Nov 2024 17:59:49 +0100 Subject: [PATCH 2/4] Discard changes to recipes/date/all/conanfile.py --- recipes/date/all/conanfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/date/all/conanfile.py b/recipes/date/all/conanfile.py index f8023348ebeaa..8db1625fd6096 100644 --- a/recipes/date/all/conanfile.py +++ b/recipes/date/all/conanfile.py @@ -11,11 +11,11 @@ class DateConan(ConanFile): name = "date" - description = "A date and time library based on the C++11/14/17 header" - license = "MIT" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/HowardHinnant/date" + description = "A date and time library based on the C++11/14/17 header" topics = ("datetime", "timezone", "calendar", "time", "iana-database") + license = "MIT" package_type = "library" settings = "os", "arch", "compiler", "build_type" options = { From 8233c6ee3e41d57bc51c6a310299c4f29914c8c9 Mon Sep 17 00:00:00 2001 From: Luis Caro Campos <3535649+jcar87@users.noreply.github.com> Date: Tue, 12 Nov 2024 17:05:11 +0000 Subject: [PATCH 3/4] date: simplify test package --- recipes/date/all/test_package/CMakeLists.txt | 4 +- .../date/all/test_package/test_package.cpp | 57 ++----------------- .../date/all/test_v1_package/CMakeLists.txt | 8 --- recipes/date/all/test_v1_package/conanfile.py | 18 ------ 4 files changed, 8 insertions(+), 79 deletions(-) delete mode 100644 recipes/date/all/test_v1_package/CMakeLists.txt delete mode 100644 recipes/date/all/test_v1_package/conanfile.py diff --git a/recipes/date/all/test_package/CMakeLists.txt b/recipes/date/all/test_package/CMakeLists.txt index 276e986aaf0a2..7a4b3fe1c9b08 100644 --- a/recipes/date/all/test_package/CMakeLists.txt +++ b/recipes/date/all/test_package/CMakeLists.txt @@ -1,7 +1,7 @@ -cmake_minimum_required(VERSION 3.8) +cmake_minimum_required(VERSION 3.15) project(test_package LANGUAGES CXX) -find_package(date REQUIRED CONFIG) +find_package(date REQUIRED) add_executable(${PROJECT_NAME} test_package.cpp) target_link_libraries(${PROJECT_NAME} PRIVATE date::date) diff --git a/recipes/date/all/test_package/test_package.cpp b/recipes/date/all/test_package/test_package.cpp index a636960b5c6aa..8006dfe07f25c 100644 --- a/recipes/date/all/test_package/test_package.cpp +++ b/recipes/date/all/test_package/test_package.cpp @@ -1,62 +1,17 @@ #include "date/date.h" #include "date/tz.h" - -#include -#include #include -#include - -class ZoneOffset { -public: - explicit ZoneOffset(std::chrono::minutes offset) - : _offset(offset) {} - - template - auto to_local(date::sys_time tp) const - -> date::local_time::type> { - using namespace date; - using namespace std::chrono; - using LT = date::local_time::type>; - return LT{(tp + _offset).time_since_epoch()}; - } - - template - auto to_sys(date::local_time tp) const - -> date::sys_time::type> { - using namespace date; - using namespace std::chrono; - using ST = date::sys_time::type>; - return ST{(tp - _offset).time_since_epoch()}; - } - -private: - std::chrono::minutes _offset; -}; int main() { - using std::chrono::hours; - using std::chrono::milliseconds; - using std::chrono::minutes; - using namespace date; - - auto date1 = 2015_y/March/22; - std::cout << date1 << '\n'; - auto date2 = March/22/2015; - std::cout << date2 << '\n'; - auto date3 = 22_d/March/2015; - std::cout << date3 << '\n'; - - ZoneOffset p3_45{hours{3} + minutes{45}}; - zoned_time zt{&p3_45, floor(std::chrono::system_clock::now())}; - std::cout << zt.get_sys_time() << " (sys time)\n"; - std::cout << zt.get_local_time() << " (local time)\n"; + const date::year_month_day conan_two(date::year(2023), date::month(2), date::day(22)); + std::cout << "Conan was released on: " << conan_two << std::endl; #ifndef DATE_HEADER_ONLY try { - auto tz = date::current_zone()->name(); - std::cout << "timezone: " << tz << std::endl; - } catch (const std::exception & e) { - std::cout << "exception caught " << e.what() << std::endl; + const date::time_zone* tz = date::current_zone(); + } + catch (const std::exception & e) { + std::cout << "exception caught " << e.what() << std::endl; } #endif diff --git a/recipes/date/all/test_v1_package/CMakeLists.txt b/recipes/date/all/test_v1_package/CMakeLists.txt deleted file mode 100644 index 925ecbe19e448..0000000000000 --- a/recipes/date/all/test_v1_package/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ - ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/date/all/test_v1_package/conanfile.py b/recipes/date/all/test_v1_package/conanfile.py deleted file mode 100644 index 09dc5f4a353ed..0000000000000 --- a/recipes/date/all/test_v1_package/conanfile.py +++ /dev/null @@ -1,18 +0,0 @@ -from conans import ConanFile, CMake, tools -import os - - -class TestPackageConan(ConanFile): - settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" - - def build(self): - cmake = CMake(self) - cmake.definitions["DATE_HEADER_ONLY"] = self.options["date:header_only"] - cmake.configure() - cmake.build() - - def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) From d5e6721b35d6bc4413f01454cb341a82d5c582ea Mon Sep 17 00:00:00 2001 From: Luis Caro Campos <3535649+jcar87@users.noreply.github.com> Date: Tue, 12 Nov 2024 17:14:21 +0000 Subject: [PATCH 4/4] Dont print exception error (no need) --- recipes/date/all/test_package/test_package.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/recipes/date/all/test_package/test_package.cpp b/recipes/date/all/test_package/test_package.cpp index 8006dfe07f25c..4ccf632e8e904 100644 --- a/recipes/date/all/test_package/test_package.cpp +++ b/recipes/date/all/test_package/test_package.cpp @@ -11,7 +11,6 @@ int main() { const date::time_zone* tz = date::current_zone(); } catch (const std::exception & e) { - std::cout << "exception caught " << e.what() << std::endl; } #endif