A simple Node.js utility for parsing Schyntax schedule strings, and finding the next scheduled event time.
Schyntax is not a scheduled task runner. It simply helps you determine when a task should run. If you're looking for a task runner built on Schyntax, try Schtick.
npm install schyntax
Find the next weekday (Monday through Friday) at 16:00 UTC:
var schyntax = ;var schedule = ;console;
Find noon on the next day which isn't the Fourth of July or December 25th:
var schedule = ;console;
Find the next seven dates which are either 10AM on a weekday, or noon on a weekend by using schedule groups (expressions grouped inside curly braces):
var schedule = ;var dates = ;var d = null;for var i = 0; i < 7; i++d = schedulenextd;dates;console;
Accepts an optional
after argument in the form of a
Date object or numeric Unix timestamp in milliseconds. If no argument is provided, the current time is used.
Date object representing the next timestamp which matches the scheduling criteria. The date will always be greater than, never equal to,
after. If no timestamp could be found which matches the scheduling criteria, a
ValidTimeNotFoundError error is thrown, which generally indicates conflicting scheduling criteria (explicitly including and excluding the same day or time).
schyntax#next accept that its return value will be less than or equal to the current time or optional
atOrBefore argument. This means that if you want to find the last n-previous events, you should subtract at least a millisecond from the result before passing it back to the function. For example, here is the reverse of one of the prior examples:
var schedule = ;var dates = ;var d = null;for var i = 0; i < 7; i++d = schedulepreviousd ? d - 1 : null;dates;console;
For complete documentation on the Schyntax domain-specific language, see the Schyntax project.