From de143e8b8eea0615e8c660c7408a3fd075b5b45c Mon Sep 17 00:00:00 2001 From: "Dr. Nicholas J. Kinar" Date: Sun, 1 Jun 2025 02:51:30 -0600 Subject: [PATCH] Added code to ensure that code snippets in Readme compile. (#46) * 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. --------- Co-authored-by: Per Malmberg --- 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); } ```