Skip to content

Commit

Permalink
date: support gcc14 on test_package (#23946)
Browse files Browse the repository at this point in the history
* date: support gcc14 on test_package

* Discard changes to recipes/date/all/conanfile.py

* date: simplify test package

* Dont print exception error (no need)

---------

Co-authored-by: Abril Rincón Blanco <rubenrb@jfrog.com>
Co-authored-by: Abril Rincón Blanco <git@rinconblanco.es>
Co-authored-by: Luis Caro Campos <3535649+jcar87@users.noreply.github.com>
  • Loading branch information
4 people authored Nov 12, 2024
1 parent c40fe38 commit 5191afe
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 77 deletions.
4 changes: 2 additions & 2 deletions recipes/date/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
54 changes: 5 additions & 49 deletions recipes/date/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -1,60 +1,16 @@
#include "date/date.h"
#include "date/tz.h"

#include <chrono>
#include <cstdlib>
#include <iostream>
#include <type_traits>

class ZoneOffset {
public:
explicit ZoneOffset(std::chrono::minutes offset)
: _offset(offset) {}

template <class Duration>
auto to_local(date::sys_time<Duration> tp) const
-> date::local_time<typename std::common_type<Duration, std::chrono::minutes>::type> {
using namespace date;
using namespace std::chrono;
using LT = local_time<typename std::common_type<Duration, minutes>::type>;
return LT{(tp + _offset).time_since_epoch()};
}

template <class Duration>
auto to_sys(date::local_time<Duration> tp) const
-> date::sys_time<typename std::common_type<Duration, std::chrono::minutes>::type> {
using namespace date;
using namespace std::chrono;
using ST = sys_time<typename std::common_type<Duration, minutes>::type>;
return ST{(tp - _offset).time_since_epoch()};
}

private:
std::chrono::minutes _offset;
};

int main() {
using namespace std::chrono;
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<milliseconds, ZoneOffset*> zt{&p3_45, floor<milliseconds>(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) {
}
#endif

Expand Down
8 changes: 0 additions & 8 deletions recipes/date/all/test_v1_package/CMakeLists.txt

This file was deleted.

18 changes: 0 additions & 18 deletions recipes/date/all/test_v1_package/conanfile.py

This file was deleted.

0 comments on commit 5191afe

Please sign in to comment.