Express crontabs as human friendly phrases

Overview

HuCron

GitHub tag (latest SemVer) Github Actions Status Php Version License

HuCron turns human readable strings about time and turns them into valid crontabs.

phppkg/hucron is froked from the https://github.com/ajbdev/cronlingo

Install

composer install phppkg/hucron

Usage

There are some examples for parse human statement.

Shortcuts statement

use HuCron\HuCron;

echo HuCron::fromStatement('@hourly'); // "0 * * * *"

echo HuCron::fromStatement('@daliy'); // "0 0 * * *"

echo HuCron::fromStatement('@weekly'); // "0 0 * * 0"

echo HuCron::fromStatement('@monthly'); // "0 0 1 * *"

// echo HuCron::fromStatement('@yearly');
echo HuCron::fromStatement('@annually'); // "0 0 1 1 *"

Custom statement

use HuCron\HuCron;

echo HuCron::fromStatement('Every day at midnight');
// "0 0 * * *"

echo HuCron::fromStatement('Every 15 minutes at midnight on the weekend');
// "*/15 0 * * 0,6"

echo HuCron::fromStatement('Every other minute in August at noon on a weekday');
// "*/2 12 * 8 1,2,3,4,5"

echo HuCron::fromStatement('The 1st day in April at midnight');
// "0 0 1 4 *"

echo HuCron::fromStatement('Every day on the weekday at 2:25pm');
// "25 14 * * 1,2,3,4,5"

Syntax

HuCron identifies the parts of a string with specific time-related keywords such as "on, to, at" and uses this to deduce the time meaning and convert it into part of a cron tab. It's not particular about the order of these statements. Here's a brief list of things that it will pick up and parse into a crontab:

  • Periods (daily, weekly, monthly)
  • Exact times (9:30 PM, 8a, 3p)
  • Meridiems (AM/PM/A/P)
  • Intervals (1st, second, other, ninth, etc)
  • Specific fields (second, minute, hour, day, month)
  • Day of week (sunday, monday etc)
  • 12 o'clocks (noon, midnight)
  • Lists (e.g. 5 to 12 minutes)
  • Month names (january, february, etc)
  • Weekend / weekday

What's a cron tab?

A cron tab is an expression that defines a recurring period of time.

It looks something like this:

*    *    *    *    *
-    -    -    -    -
|    |    |    |    |
|    |    |    |    +----- day of week (0 - 7) (Sunday=0 or 7)
|    |    |    +---------- month (1 - 12)
|    |    +--------------- day of month (1 - 31)
|    +-------------------- hour (0 - 23)
+------------------------- min (0 - 59)

From Wikipedia:

The software utility Cron is a time-based job scheduler in Unix-like computer operating systems. People who set up and maintain software environments use cron to schedule jobs (commands or shell scripts) to run periodically at fixed times, dates, or intervals. It typically automates system maintenance or administration—though its general-purpose nature makes it useful for things like connecting to the Internet and downloading email at regular intervals.

Related

LICENSE

MIT

You might also like...
PHP implementation of Rapid Automatic Keyword Exraction algorithm (RAKE) for extracting multi-word phrases from text

PHP implementation of Rapid Automatic Keyword Exraction algorithm (RAKE) for extracting multi-word phrases from text.

Extract colors from an image like a human would do.

ColorExtractor Extract colors from an image like a human would do. Install Via Composer $ composer require league/color-extractor:0.3.* Usage require

Extract colors from an image like a human would do.

ColorExtractor Extract colors from an image like a human would do. Install Via Composer $ composer require league/color-extractor:0.3.* Usage require

OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures  all the essential functionalities required for any enterprise.
OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures all the essential functionalities required for any enterprise.

OrangeHRM Open Source Application OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures all the essential functionalities

The new, most powerful Comic Reader ever created by the human race. Reworked by an Otaku.
The new, most powerful Comic Reader ever created by the human race. Reworked by an Otaku.

FoOlSlideX The new, most powerful Comic Reader ever created by the human race. Reworked by an Otaku. Requirements PHP greater than 7.0 and everything

STEAM education curriculum centered on building a new civilization entirely from trash, which provides all human needs for free directly to the local community

TRASH ACADEMY STEAM(Science Technology Engineering Art Math) education curriculum centered around building self-replicating technology from trash whic

Instagram automation represents the use of third-party software to manage your account, carry out tasks and/or interact with users without a human present.  Bulit in Laravel Framework
Instagram automation represents the use of third-party software to manage your account, carry out tasks and/or interact with users without a human present. Bulit in Laravel Framework

How to Deploy laravel project to heroku Video Link : https://youtu.be/7Nq_a2QiaHo Home Page Login Page Dashboard Page About Laravel Laravel is a web a

Automatic human timestamps for Laravel Eloquent models.

Automatic human timestamp properties in Laravel This package provides a trait you can add to an Eloquent model that will automatically create human-re

Text - An experiment with WebSockets and the human condition.

An experiment with WebSockets and the human condition. I wanted to learn how to use WebSockets in pure PHP and JavaScript, so I came up with the simpl

🧾 Online test site with the human sciences theme. Using: HTML5, CSS3, Js., PHP7 and MySQL. 🚀
🧾 Online test site with the human sciences theme. Using: HTML5, CSS3, Js., PHP7 and MySQL. 🚀

form-ciencias-humanas 🚀 Technologies Lunacy HTML5 CSS3 PHP7 MYSQL Animate.css Illustrations from icons8: Earth care from Anna Antipina Earth and Moon

ColorExtractor: Extract colors from an image like a human would do

ColorExtractor Extract colors from an image like a human would do. Install Via Composer $ composer require league/color-extractor:0.3.* Usage require

Sentrifugo is a FREE and powerful Human Resource Management System (HRMS) that can be easily configured to meet your organizational needs.

Sentrifugo Sentrifugo is a free and powerful new-age Human Resource Management System that can be easily configured to adapt to your organizational pr

🦉 human-readable regular expressions for PHP

RegExpBuilder integrates regular expressions into the programming language, thereby making them easy to read and maintain. Regular Expressions are created by using chained methods and variables such as arrays or strings.

Requests - a HTTP library written in PHP, for human beings

Requests is a HTTP library written in PHP, for human beings. It is roughly based on the API from the excellent Requests Python library. Requests is ISC Licensed (similar to the new BSD license) and has no dependencies, except for PHP 5.6+.

Herbie is a simple Flat-File CMS- und Blogsystem based on human readable text files

Herbie is a simple Flat-File CMS- und Blogsystem based on human readable text files

This component, based on the Symfony serializer and async-aws, is a human-readable and quick abstraction to easily store serialized objects in DynamoDB 🚀.

DynamoDB Storable This component, based on the Symfony serializer and async-aws, is a human-readable and quick abstraction to easily store serialized

PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD. PHPMD can be seen as an user friendly frontend application for the raw metrics stream measured by PHP Depend.

PHPMD PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD. PHPMD can be seen as an user friendly

😎 Tracy: the addictive tool to ease debugging PHP code for cool developers. Friendly design, logging, profiler, advanced features like debugging AJAX calls or CLI support. You will love it.
😎 Tracy: the addictive tool to ease debugging PHP code for cool developers. Friendly design, logging, profiler, advanced features like debugging AJAX calls or CLI support. You will love it.

Tracy - PHP debugger Introduction Tracy library is a useful helper for everyday PHP programmers. It helps you to: quickly detect and correct errors lo

Comments
  • Update phpunit/phpunit requirement from ^7.5 || ^8.5 to ^9.5.10

    Update phpunit/phpunit requirement from ^7.5 || ^8.5 to ^9.5.10

    Updates the requirements on phpunit/phpunit to permit the latest version.

    Changelog

    Sourced from phpunit/phpunit's changelog.

    [9.5.10] - 2021-09-25

    Changed

    • PHPUnit no longer converts PHP deprecations to exceptions by default (configure convertDeprecationsToExceptions="true" to enable this)
    • The PHPUnit XML configuration file generator now configures convertDeprecationsToExceptions="true"

    Fixed

    • #4772: TestDox HTML report not displayed correctly when browser has custom colour settings

    [9.5.9] - 2021-08-31

    Fixed

    • #4750: Automatic return value generation leads to invalid (and superfluous) test double code generation when a stubbed method returns *|false
    • #4751: Configuration validation fails when using brackets in glob pattern

    [9.5.8] - 2021-07-31

    Fixed

    • #4740: phpunit.phar does not work with PHP 8.1

    [9.5.7] - 2021-07-19

    Fixed

    • #4720: PHPUnit does not verify its own PHP extension requirements
    • #4735: Automated return value generation does not work for stubbed methods that return *|false

    [9.5.6] - 2021-06-23

    Changed

    • PHPUnit now errors out on startup when PHP_VERSION contains a value that is not compatible with version_compare(), for instance X.Y.Z-(to be removed in future macOS)

    [9.5.5] - 2021-06-05

    Changed

    • The test result cache (the storage for which is implemented in PHPUnit\Runner\DefaultTestResultCache) no longer uses PHP's serialize() and unserialize() functions for persistence. It now uses a versioned JSON format instead that is independent of PHP implementation details (see #3581 and #4662 for examples why this is a problem). When PHPUnit tries to load the test result cache from a file that does not exist, or from a file that does not contain data in JSON format, or from a file that contains data in a JSON format version other than the one used by the currently running PHPUnit version, then this is considered to be a "cache miss". An empty DefaultTestResultCache object is created in this case. This should also prevent PHPUnit from crashing when trying to load a test result cache file created by a different version of PHPUnit (see #4580 for example).

    Fixed

    • #4632: TestDox result printer does not handle repeated test execution correctly
    • #4678: Stubbed methods with iterable return types should return empty array by default
    • #4692: Annotations in single-line doc-comments are not handled correctly
    • #4694: TestCase::getMockFromWsdl() does not work with PHP 8.1-dev

    ... (truncated)

    Commits

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 1
Owner
PHPPkg
Some useful package for PHP
PHPPkg
Instagram automation represents the use of third-party software to manage your account, carry out tasks and/or interact with users without a human present. Bulit in Laravel Framework

How to Deploy laravel project to heroku Video Link : https://youtu.be/7Nq_a2QiaHo Home Page Login Page Dashboard Page About Laravel Laravel is a web a

null 1 Dec 3, 2021
Express crontabs as human friendly phrases

CRON Lingo CronLingo turns human readable strings about time and turns them into valid crontabs. Examples: echo CronLingo::fromExpression('Every day a

null 149 Dec 30, 2022
cybercog 996 Dec 28, 2022
Express.php is a new HTTP - Server especially made for RESTful APIs written in PHP.

express.php Express.php is a new HTTP - Server especially made for RESTful APIs written in PHP. Features Fast The Library is handles requests fast and

null 5 Aug 19, 2022
🦭 Kirby, but headless only – KQL with bearer token, Express-esque middlewares & more

Kirby Headless Starter ℹ️ Send a Bearer test authorization header with a request to the live playground to test this headless starter. This starter ki

Johann Schopplich 36 Dec 28, 2022
PHPRouter is an easy-to-use, fast, and flexible PHP router package with express-style routing.

PHP-Router is a modern, fast, and adaptable composer package that provides express-style routing in PHP without a framework.

Ayodeji O. 4 Oct 20, 2022
On International Talk Like a Pirate Day (September 19th), this filter changes all appropriate English phrases and words into pirate-speak.

Pirate This module is a simple filter that, when enabled, will change your posts to "Pirate talk" on September 19th for Talk like a Pirate Day Install

Backdrop CMS contributed projects 3 Oct 26, 2021
Composer package providing HTTP Methods, Status Codes and Reason Phrases for PHP

HTTP Enums For PHP 8.1 and above This package provides HTTP Methods, Status Codes and Reason Phrases as PHP 8.1+ enums All IANA registered HTTP Status

Alexander Pas 72 Dec 23, 2022
Searches for multilingual phrases in Laravel project and automatically generates language files for you.

Laravel Lang Generator Searches for multilingual phrases in a Laravel project and automatically generates language files for you. You can search for n

Gleb 5 Oct 19, 2022