{"id":3126,"date":"2018-08-30T19:45:12","date_gmt":"2018-08-30T17:45:12","guid":{"rendered":"https:\/\/mariusbancila.ro\/blog\/?p=3126"},"modified":"2018-08-30T13:27:12","modified_gmt":"2018-08-30T11:27:12","slug":"croncpp-a-cpp-library-for-cron-expressions","status":"publish","type":"post","link":"https:\/\/mariusbancila.ro\/blog\/2018\/08\/30\/croncpp-a-cpp-library-for-cron-expressions\/","title":{"rendered":"croncpp &#8211; a C++ library for CRON expressions"},"content":{"rendered":"<p>A CRON expression is a string composed of six fields (in some implementation seven), separated by a whites space, representing a time schedule. CRON expressions are used in various job schedulers (such as the Linux job scheduler, the Quartz scheduler, Azure scheduler for functions, etc.). Recently, I have written a C++ library for parsing such expressions and determining the next occurrence of the scheduled time. The library is called <strong>croncpp<\/strong>. It is written in C++17, is header-only, open-source and cross-platform, and can be found on <a href=\"https:\/\/github.com\/mariusbancila\/croncpp\" target=\"_blank\" rel=\"noopener\">GitHub<\/a>.<\/p>\n<p><!-- more --><\/p>\n<h3>CRON expressions<\/h3>\n<p>The general form of a CRON expression is the following (with the\u00a0<code>years<\/code>\u00a0being optional):<\/p>\n<pre>&lt;seconds&gt; &lt;minutes&gt; &lt;hours&gt; &lt;days of month&gt; &lt;months&gt; &lt;days of week&gt; &lt;years&gt;<\/pre>\n<p>The following values are allowed for these fields:<\/p>\n<table>\n<thead>\n<tr>\n<th>Field<\/th>\n<th>Required<\/th>\n<th>Allowed value *<\/th>\n<th>Allowed value (alternative 1) **<\/th>\n<th>Allowed value (alternative 2) ***<\/th>\n<th>Allowed special characters<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>seconds<\/td>\n<td>yes<\/td>\n<td>0-59<\/td>\n<td>0-59<\/td>\n<td>0-59<\/td>\n<td><tt>*<\/tt>\u00a0<tt>,<\/tt>\u00a0<tt>-<\/tt><\/td>\n<\/tr>\n<tr>\n<td>minutes<\/td>\n<td>yes<\/td>\n<td>0-59<\/td>\n<td>0-59<\/td>\n<td>0-59<\/td>\n<td><tt>*<\/tt>\u00a0<tt>,<\/tt>\u00a0<tt>-<\/tt><\/td>\n<\/tr>\n<tr>\n<td>hours<\/td>\n<td>yes<\/td>\n<td>0-23<\/td>\n<td>0-23<\/td>\n<td>0-23<\/td>\n<td><tt>*<\/tt>\u00a0<tt>,<\/tt>\u00a0<tt>-<\/tt><\/td>\n<\/tr>\n<tr>\n<td>days of month<\/td>\n<td>1-31<\/td>\n<td>1-31<\/td>\n<td>1-31<\/td>\n<td>1-31<\/td>\n<td><tt>*<\/tt>\u00a0<tt>,<\/tt>\u00a0<tt>-<\/tt>\u00a0<tt>?<\/tt>\u00a0<tt>L<\/tt>\u00a0<tt>W<\/tt><\/td>\n<\/tr>\n<tr>\n<td>months<\/td>\n<td>yes<\/td>\n<td>1-12<\/td>\n<td>0-11<\/td>\n<td>1-12<\/td>\n<td><tt>*<\/tt>\u00a0<tt>,<\/tt>\u00a0<tt>-<\/tt><\/td>\n<\/tr>\n<tr>\n<td>days of week<\/td>\n<td>yes<\/td>\n<td>0-6<\/td>\n<td>1-7<\/td>\n<td>1-7<\/td>\n<td><tt>*<\/tt>\u00a0<tt>,<\/tt>\u00a0<tt>-<\/tt>\u00a0<tt>?<\/tt>\u00a0<tt>L<\/tt>\u00a0<tt>#<\/tt><\/td>\n<\/tr>\n<tr>\n<td>years<\/td>\n<td>no<\/td>\n<td>1970-2099<\/td>\n<td>1970-2099<\/td>\n<td>1970-2099<\/td>\n<td><tt>*<\/tt>\u00a0<tt>,<\/tt>\u00a0<tt>-<\/tt><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>* &#8211; As described on Wikipedia\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/Cron\" rel=\"nofollow\">Cron<\/a><\/p>\n<p>** &#8211; As described on Oracle\u00a0<a href=\"https:\/\/docs.oracle.com\/cd\/E12058_01\/doc\/doc.1014\/e12030\/cron_expressions.htm\" rel=\"nofollow\">Role Manager Integration Guide &#8211; A Cron Expressions<\/a><\/p>\n<p>*** &#8211; As described for the Quartz scheduler\u00a0<a href=\"http:\/\/www.quartz-scheduler.org\/documentation\/quartz-1.x\/tutorials\/crontrigger\" rel=\"nofollow\">CronTrigger Tutorial<\/a><\/p>\n<p>The special characters have the following meaning:<\/p>\n<table>\n<thead>\n<tr>\n<th>Special character<\/th>\n<th>Meaning<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><tt>*<\/tt><\/td>\n<td>all values<\/td>\n<td>selects all values within a field<\/td>\n<\/tr>\n<tr>\n<td><tt>?<\/tt><\/td>\n<td>no specific value<\/td>\n<td>specify one field and leave the other unspecified<\/td>\n<\/tr>\n<tr>\n<td><tt>-<\/tt><\/td>\n<td>range<\/td>\n<td>specify ranges<\/td>\n<\/tr>\n<tr>\n<td><tt>,<\/tt><\/td>\n<td>comma<\/td>\n<td>specify additional values<\/td>\n<\/tr>\n<tr>\n<td><tt>\/<\/tt><\/td>\n<td>slash<\/td>\n<td>speficy increments<\/td>\n<\/tr>\n<tr>\n<td><tt>L<\/tt><\/td>\n<td>last<\/td>\n<td>last day of the month or last day of the week<\/td>\n<\/tr>\n<tr>\n<td><tt>W<\/tt><\/td>\n<td>weekday<\/td>\n<td>the weekday nearest to the given day<\/td>\n<\/tr>\n<tr>\n<td><tt>#<\/tt><\/td>\n<td>nth<\/td>\n<td>specify the Nth day of the month<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Examples:<\/p>\n<table>\n<thead>\n<tr>\n<th>CRON<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>* * * * * *<\/td>\n<td>Every second<\/td>\n<\/tr>\n<tr>\n<td>*\/5 * * * * ?<\/td>\n<td>Every 5 seconds<\/td>\n<\/tr>\n<tr>\n<td>0 *\/5 *\/2 * * ?<\/td>\n<td>Every 5 minutes, every 2 hours<\/td>\n<\/tr>\n<tr>\n<td>0 *\/2 *\/2 ? *\/2 *\/2<\/td>\n<td>Every 2 minutes, every 2 hours, every 2 days of the week, every 2 months<\/td>\n<\/tr>\n<tr>\n<td>0 15 10 * * ? *<\/td>\n<td>10:15 AM every day<\/td>\n<\/tr>\n<tr>\n<td>0 0\/5 14 * * ?<\/td>\n<td>Every 5 minutes starting at 2 PM and ending at 2:55 PM, every day<\/td>\n<\/tr>\n<tr>\n<td>0 10,44 14 ? 3 WED<\/td>\n<td>2:10 PM and at 2:44 PM every Wednesday of March<\/td>\n<\/tr>\n<tr>\n<td>0 15 10 ? * MON-FRI<\/td>\n<td>10:15 AM every Monday, Tuesday, Wednesday, Thursday and Friday<\/td>\n<\/tr>\n<tr>\n<td>0 15 10 L * ?<\/td>\n<td>10:15 AM on the last day of every month<\/td>\n<\/tr>\n<tr>\n<td>0 0 12 1\/5 * ?<\/td>\n<td>12 PM every 5 days every month, starting on the first day of the month<\/td>\n<\/tr>\n<tr>\n<td>0 11 11 11 11 ?<\/td>\n<td>Every November 11th at 11:11 AM<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>croncpp library<\/h3>\n<p>There are two main functionalities provided by the library: parsing a CRON expression and computing the next occurence of the scheduled time.<\/p>\n<p>To parse a CRON expression use <tt>make_cron()<\/tt> as follows:<\/p>\n<pre class=\"lang:c++ decode:true \">try\r\n{\r\n   auto cron = cron::make_cron(\"* 0\/5 * * * ?\");\r\n}\r\ncatch (cron::bad_cronexpr const &amp; ex)\r\n{\r\n   std::cerr &lt;&lt; ex.what() &lt;&lt; '\\n';\r\n}<\/pre>\n<p><tt>make_cron()<\/tt> returns an object of the type <tt>cronexpr<\/tt>. The actual content of this object is not of real interest and, in fact, all its details are private. You can consider this as an implementation detail object that contains the necessary information for a CRON expression, in order to compute the next occurence of the time schedule, which is the actual important operation we are interested in.<\/p>\n<p>To get the next occurence of the time schedule use the <tt>cron_next()<\/tt> function as follows:<\/p>\n<pre class=\"lang:c++ decode:true \">try\r\n{\r\n   auto cron = cron::make_cron(\"* 0\/5 * * * ?\");\r\n   \r\n   std::time_t now = std::time(0);\r\n   std::time_t next = cron::cron_next(cron, now);   \r\n}\r\ncatch (cron::bad_cronexpr const &amp; ex)\r\n{\r\n   std::cerr &lt;&lt; ex.what() &lt;&lt; '\\n';\r\n}<\/pre>\n<p>Alternatively, you can use <tt>std::tm<\/tt> instead of <tt>std::time_t<\/tt>:<\/p>\n<pre class=\"lang:c++ decode:true \">try\r\n{\r\n   auto cron = cron::make_cron(\"* 0\/5 * * * ?\");\r\n   \r\n   std::tm time = cron::utils::to_tm(\"2018-08-08 20:30:45\");\r\n   std::tm next = cron::cron_next(cron, time);\r\n}\r\ncatch (cron::bad_cronexpr const &amp; ex)\r\n{\r\n   std::cerr &lt;&lt; ex.what() &lt;&lt; '\\n';\r\n}<\/pre>\n<p>When you use these functions as shown above you implicitly use the standard supported values for the fields, as described in the first section. However, you can use any other settings. The ones provided with the library are called <tt>cron_standard_traits<\/tt>, <tt>cron_oracle_traits<\/tt> and <tt>cron_quartz_traits<\/tt> (coresponding to the aforementioned settings).<\/p>\n<pre class=\"lang:c++ decode:true \">try\r\n{\r\n   auto cron = cron::make_cron&lt;cron_quartz_traits&gt;(\"* 0\/5 * * * ?\");\r\n   \r\n   std::time_t now = std::time(0);\r\n   std::time_t next = cron::cron_next&lt;cron_quartz_traits&gt;(cron, now);   \r\n}\r\ncatch (cron::bad_cronexpr const &amp; ex)\r\n{\r\n   std::cerr &lt;&lt; ex.what() &lt;&lt; '\\n';\r\n}<\/pre>\n<h3>Performance<\/h3>\n<p>I tried to see how the library performs, both on Windows and Mac, although the machines I used for testing were pretty different. I used the following:<\/p>\n<p>VC++ 15.7.4 running on:<\/p>\n<ul>\n<li>Windows 10 Enterprise build 17134<\/li>\n<li>Intel Core i7, 2.67 GHz, 1 CPU \/ 4 cores \/ 8 logical, 6 RAM<\/li>\n<\/ul>\n<p>GCC 8.1.0 \/ Clang LLVM 9.1.0 running on:<\/p>\n<ul>\n<li>macOS 10.13.5<\/li>\n<li>Intel Core i7, 1.7 GHz, 1 CPU \/ 2 cores, 8 GB RAM<\/li>\n<\/ul>\n<p>The following results are the average (in microseconds) for running the benchmark program ten times on these machines and compilers (all with release settings):<\/p>\n<table>\n<thead>\n<tr>\n<th>VC++ 32-bit<\/th>\n<th>VC++ 64-bit<\/th>\n<th>GCC 32-bit<\/th>\n<th>GCC 64-bit<\/th>\n<th>Clang 64-bit<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>11.52<\/td>\n<td>8.30<\/td>\n<td>8.95<\/td>\n<td>7.03<\/td>\n<td>4.48<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2018\/08\/croncpp.png\" alt=\"\" width=\"564\" height=\"371\" class=\"alignnone size-full wp-image-3132\" srcset=\"https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2018\/08\/croncpp.png 564w, https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2018\/08\/croncpp-300x197.png 300w\" sizes=\"auto, (max-width: 564px) 100vw, 564px\" \/><\/p>\n<p>I am looking forward to hearing your feedback!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A CRON expression is a string composed of six fields (in some implementation seven), separated by a whites space, representing a time schedule. CRON expressions are used in various job schedulers (such as the Linux job scheduler, the Quartz scheduler, Azure scheduler for functions, etc.). Recently, I have written a C++ library for parsing such expressions and determining the next occurrence of the scheduled time. The library is called <strong>croncpp<\/strong>. It is written in C++17, is header-only, open-source and cross-platform, and can be found on <a href=\"https:\/\/github.com\/mariusbancila\/croncpp\" target=\"_blank\" rel=\"noopener\">GitHub<\/a>.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","advgb_blocks_editor_width":"","advgb_blocks_columns_visual_guide":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[7],"tags":[451,563,491,138,384],"class_list":["post-3126","post","type-post","status-publish","format-standard","hentry","category-c","tag-c","tag-cron","tag-github","tag-library","tag-open-source"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.3 - aioseo.com -->\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Marius Bancila\"\/>\n\t<meta name=\"keywords\" content=\"c++,cron,github,library,open-source\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/mariusbancila.ro\/blog\/2018\/08\/30\/croncpp-a-cpp-library-for-cron-expressions\/\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.3\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Marius Bancila&#039;s Blog | About code. Mostly on C++\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"croncpp \u2013 a C++ library for CRON expressions\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/mariusbancila.ro\/blog\/2018\/08\/30\/croncpp-a-cpp-library-for-cron-expressions\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2018-08-30T17:45:12+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2018-08-30T11:27:12+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"croncpp \u2013 a C++ library for CRON expressions\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2018\\\/08\\\/30\\\/croncpp-a-cpp-library-for-cron-expressions\\\/#article\",\"name\":\"croncpp \\u2013 a C++ library for CRON expressions\",\"headline\":\"croncpp &#8211; a C++ library for CRON expressions\",\"author\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/08\\\/croncpp.png\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2018\\\/08\\\/30\\\/croncpp-a-cpp-library-for-cron-expressions\\\/#articleImage\",\"width\":564,\"height\":371},\"datePublished\":\"2018-08-30T19:45:12+02:00\",\"dateModified\":\"2018-08-30T13:27:12+02:00\",\"inLanguage\":\"en-US\",\"commentCount\":4,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2018\\\/08\\\/30\\\/croncpp-a-cpp-library-for-cron-expressions\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2018\\\/08\\\/30\\\/croncpp-a-cpp-library-for-cron-expressions\\\/#webpage\"},\"articleSection\":\"C++, C++, cron, github, library, open-source\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2018\\\/08\\\/30\\\/croncpp-a-cpp-library-for-cron-expressions\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/#listItem\",\"name\":\"IT\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/#listItem\",\"position\":2,\"name\":\"IT\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/#listItem\",\"name\":\"Software\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/#listItem\",\"position\":3,\"name\":\"Software\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/#listItem\",\"name\":\"C++\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/#listItem\",\"name\":\"IT\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/#listItem\",\"position\":4,\"name\":\"C++\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2018\\\/08\\\/30\\\/croncpp-a-cpp-library-for-cron-expressions\\\/#listItem\",\"name\":\"croncpp &#8211; a C++ library for CRON expressions\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/#listItem\",\"name\":\"Software\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2018\\\/08\\\/30\\\/croncpp-a-cpp-library-for-cron-expressions\\\/#listItem\",\"position\":5,\"name\":\"croncpp &#8211; a C++ library for CRON expressions\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/#listItem\",\"name\":\"C++\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#organization\",\"name\":\"Marius Bancila's Blog\",\"description\":\"About code. Mostly on C++\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/\",\"name\":\"Marius Bancila\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2018\\\/08\\\/30\\\/croncpp-a-cpp-library-for-cron-expressions\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a84dd2831d955c38355ddea55df4df260809b88f36408bc14fd4eab8f7f131c9?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Marius Bancila\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2018\\\/08\\\/30\\\/croncpp-a-cpp-library-for-cron-expressions\\\/#webpage\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2018\\\/08\\\/30\\\/croncpp-a-cpp-library-for-cron-expressions\\\/\",\"name\":\"croncpp \\u2013 a C++ library for CRON expressions\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2018\\\/08\\\/30\\\/croncpp-a-cpp-library-for-cron-expressions\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\"},\"datePublished\":\"2018-08-30T19:45:12+02:00\",\"dateModified\":\"2018-08-30T13:27:12+02:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/\",\"name\":\"Marius Bancila's Blog\",\"description\":\"About code. Mostly on C++\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"croncpp \u2013 a C++ library for CRON expressions","description":"","canonical_url":"https:\/\/mariusbancila.ro\/blog\/2018\/08\/30\/croncpp-a-cpp-library-for-cron-expressions\/","robots":"max-image-preview:large","keywords":"c++,cron,github,library,open-source","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/mariusbancila.ro\/blog\/2018\/08\/30\/croncpp-a-cpp-library-for-cron-expressions\/#article","name":"croncpp \u2013 a C++ library for CRON expressions","headline":"croncpp &#8211; a C++ library for CRON expressions","author":{"@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author"},"publisher":{"@id":"https:\/\/mariusbancila.ro\/blog\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2018\/08\/croncpp.png","@id":"https:\/\/mariusbancila.ro\/blog\/2018\/08\/30\/croncpp-a-cpp-library-for-cron-expressions\/#articleImage","width":564,"height":371},"datePublished":"2018-08-30T19:45:12+02:00","dateModified":"2018-08-30T13:27:12+02:00","inLanguage":"en-US","commentCount":4,"mainEntityOfPage":{"@id":"https:\/\/mariusbancila.ro\/blog\/2018\/08\/30\/croncpp-a-cpp-library-for-cron-expressions\/#webpage"},"isPartOf":{"@id":"https:\/\/mariusbancila.ro\/blog\/2018\/08\/30\/croncpp-a-cpp-library-for-cron-expressions\/#webpage"},"articleSection":"C++, C++, cron, github, library, open-source"},{"@type":"BreadcrumbList","@id":"https:\/\/mariusbancila.ro\/blog\/2018\/08\/30\/croncpp-a-cpp-library-for-cron-expressions\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/#listItem","position":1,"name":"Home","item":"https:\/\/mariusbancila.ro\/blog\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/#listItem","name":"IT"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/#listItem","position":2,"name":"IT","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/#listItem","name":"Software"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/#listItem","position":3,"name":"Software","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/#listItem","name":"C++"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/#listItem","name":"IT"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/#listItem","position":4,"name":"C++","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/2018\/08\/30\/croncpp-a-cpp-library-for-cron-expressions\/#listItem","name":"croncpp &#8211; a C++ library for CRON expressions"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/#listItem","name":"Software"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/2018\/08\/30\/croncpp-a-cpp-library-for-cron-expressions\/#listItem","position":5,"name":"croncpp &#8211; a C++ library for CRON expressions","previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/#listItem","name":"C++"}}]},{"@type":"Organization","@id":"https:\/\/mariusbancila.ro\/blog\/#organization","name":"Marius Bancila's Blog","description":"About code. Mostly on C++","url":"https:\/\/mariusbancila.ro\/blog\/"},{"@type":"Person","@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author","url":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/","name":"Marius Bancila","image":{"@type":"ImageObject","@id":"https:\/\/mariusbancila.ro\/blog\/2018\/08\/30\/croncpp-a-cpp-library-for-cron-expressions\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/a84dd2831d955c38355ddea55df4df260809b88f36408bc14fd4eab8f7f131c9?s=96&d=mm&r=g","width":96,"height":96,"caption":"Marius Bancila"}},{"@type":"WebPage","@id":"https:\/\/mariusbancila.ro\/blog\/2018\/08\/30\/croncpp-a-cpp-library-for-cron-expressions\/#webpage","url":"https:\/\/mariusbancila.ro\/blog\/2018\/08\/30\/croncpp-a-cpp-library-for-cron-expressions\/","name":"croncpp \u2013 a C++ library for CRON expressions","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/mariusbancila.ro\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/mariusbancila.ro\/blog\/2018\/08\/30\/croncpp-a-cpp-library-for-cron-expressions\/#breadcrumblist"},"author":{"@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author"},"creator":{"@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author"},"datePublished":"2018-08-30T19:45:12+02:00","dateModified":"2018-08-30T13:27:12+02:00"},{"@type":"WebSite","@id":"https:\/\/mariusbancila.ro\/blog\/#website","url":"https:\/\/mariusbancila.ro\/blog\/","name":"Marius Bancila's Blog","description":"About code. Mostly on C++","inLanguage":"en-US","publisher":{"@id":"https:\/\/mariusbancila.ro\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"Marius Bancila's Blog | About code. Mostly on C++","og:type":"article","og:title":"croncpp \u2013 a C++ library for CRON expressions","og:url":"https:\/\/mariusbancila.ro\/blog\/2018\/08\/30\/croncpp-a-cpp-library-for-cron-expressions\/","article:published_time":"2018-08-30T17:45:12+00:00","article:modified_time":"2018-08-30T11:27:12+00:00","twitter:card":"summary","twitter:title":"croncpp \u2013 a C++ library for CRON expressions"},"aioseo_meta_data":{"post_id":"3126","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"location":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2021-03-18 21:04:15","updated":"2025-12-12 07:50:13","seo_analyzer_scan_date":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"author_meta":{"display_name":"Marius Bancila","author_link":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/"},"featured_img":null,"jetpack_publicize_connections":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Marius Bancila","author_link":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/"},"uagb_comment_info":4,"uagb_excerpt":"A CRON expression is a string composed of six fields (in some implementation seven), separated by a whites space, representing a time schedule. CRON expressions are used in various job schedulers (such as the Linux job scheduler, the Quartz scheduler, Azure scheduler for functions, etc.). Recently, I have written a C++ library for parsing such&hellip;","coauthors":[],"tax_additional":{"categories":{"linked":["<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/\" class=\"advgb-post-tax-term\">C++<\/a>"],"unlinked":["<span class=\"advgb-post-tax-term\">C++<\/span>"]},"tags":{"linked":["<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/\" class=\"advgb-post-tax-term\">C++<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/\" class=\"advgb-post-tax-term\">cron<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/\" class=\"advgb-post-tax-term\">github<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/\" class=\"advgb-post-tax-term\">library<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/\" class=\"advgb-post-tax-term\">open-source<\/a>"],"unlinked":["<span class=\"advgb-post-tax-term\">C++<\/span>","<span class=\"advgb-post-tax-term\">cron<\/span>","<span class=\"advgb-post-tax-term\">github<\/span>","<span class=\"advgb-post-tax-term\">library<\/span>","<span class=\"advgb-post-tax-term\">open-source<\/span>"]}},"comment_count":"4","relative_dates":{"created":"Posted 8 years ago","modified":"Updated 8 years ago"},"absolute_dates":{"created":"Posted on August 30, 2018","modified":"Updated on August 30, 2018"},"absolute_dates_time":{"created":"Posted on August 30, 2018 7:45 pm","modified":"Updated on August 30, 2018 1:27 pm"},"featured_img_caption":"","series_order":"","jetpack_shortlink":"https:\/\/wp.me\/pYNdv-Oq","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts\/3126","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/comments?post=3126"}],"version-history":[{"count":10,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts\/3126\/revisions"}],"predecessor-version":[{"id":3137,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts\/3126\/revisions\/3137"}],"wp:attachment":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/media?parent=3126"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/categories?post=3126"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/tags?post=3126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}