From 357c1176d4377985ceb104c29982cf99640db981 Mon Sep 17 00:00:00 2001 From: "Dr. Nicholas J. Kinar" Date: Tue, 30 Jul 2024 19:32:00 -0600 Subject: [PATCH 1/3] Update CronScheduleTest.cpp --- test/CronScheduleTest.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/CronScheduleTest.cpp b/test/CronScheduleTest.cpp index c7347af..1d373fb 100644 --- a/test/CronScheduleTest.cpp +++ b/test/CronScheduleTest.cpp @@ -184,6 +184,15 @@ SCENARIO("Examples from README.md") DT(2018_y / 03 / 1, hours{12}, minutes{13}, seconds{48}) })); + REQUIRE(test("0 * * * * ?", DT(2018_y / 03 / 1, hours{ 12 }, minutes{ 0 }, seconds{ 0 }), + { + DT(2018_y / 03 / 1, hours{12}, minutes{1}, seconds{0}), + DT(2018_y / 03 / 1, hours{12}, minutes{2}, seconds{0}), + DT(2018_y / 03 / 1, hours{12}, minutes{3}, seconds{0}), + DT(2018_y / 03 / 1, hours{12}, minutes{4}, seconds{0}) + })); + + REQUIRE(test("0 0 12 * * MON-FRI", DT(2018_y / 03 / 10, hours{12}, minutes{13}, seconds{45}), { DT(2018_y / 03 / 12, hours{12}), From 94835ea52a17e2d465c7c2280993591365710f20 Mon Sep 17 00:00:00 2001 From: "Dr. Nicholas J. Kinar" Date: Fri, 2 Aug 2024 10:44:14 -0600 Subject: [PATCH 2/3] Update CronScheduleTest.cpp Edited code that was causing test to fail. --- test/CronScheduleTest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/CronScheduleTest.cpp b/test/CronScheduleTest.cpp index 1d373fb..ee16f7b 100644 --- a/test/CronScheduleTest.cpp +++ b/test/CronScheduleTest.cpp @@ -184,7 +184,7 @@ SCENARIO("Examples from README.md") DT(2018_y / 03 / 1, hours{12}, minutes{13}, seconds{48}) })); - REQUIRE(test("0 * * * * ?", DT(2018_y / 03 / 1, hours{ 12 }, minutes{ 0 }, seconds{ 0 }), + REQUIRE(test("0 * * * * ?", DT(2018_y / 03 / 1, hours{ 12 }, minutes{ 0 }, seconds{ 10 }), { DT(2018_y / 03 / 1, hours{12}, minutes{1}, seconds{0}), DT(2018_y / 03 / 1, hours{12}, minutes{2}, seconds{0}), @@ -221,4 +221,4 @@ SCENARIO("Examples from README.md") SCENARIO("Unable to calculate time point") { REQUIRE_FALSE(test( "0 0 * 31 FEB *", DT(2021_y / 1 / 1), DT(2022_y / 1 / 1))); -} \ No newline at end of file +} From 186cfa4b3bbd8173c3b3516797e1f9d6d763c072 Mon Sep 17 00:00:00 2001 From: "Dr. Nicholas J. Kinar" Date: Sat, 31 May 2025 20:58:07 -0600 Subject: [PATCH 3/3] Update README.md Added missing stream insertion operator to example. Also, header files for chrono and thread as well as a missing namespace for literals added. --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9f67141..d06f4c6 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,16 @@ A C++ scheduling library using cron formatting. Libcron offers an easy to use API to add callbacks with corresponding cron-formatted strings: ``` +#include +#include +#include +#include +using namespace std::chrono_literals; + libcron::Cron cron; cron.add_schedule("Hello from Cron", "* * * * * ?", [=](auto&) { - std::cout << "Hello from libcron!" std::endl; + std::cout << "Hello from libcron!" << std::endl; }); ``` @@ -19,7 +25,7 @@ To trigger the execution of callbacks, one must call `libcron::Cron::tick` at le while(true) { cron.tick(); - std::this_thread::sleep_for(500mS); + std::this_thread::sleep_for(500ms); } ```