Git Product home page Git Product logo

cs-schyntax's Introduction

C# Schyntax

NuGet version Build status Supported Schyntax Version: 1.0.1

Schyntax is a domain-specific language for defining event schedules in a terse, but readable, format. For example, if you want something to run every five minutes during work hours on weekdays, you could write days(mon..fri) hours(9..<17) min(*%5). This project is the reference implementation of Schyntax.

Usage

This library is NOT a scheduled task runner. Most likely, you'll want to use Schtick, which is a scheduled task runner built on top of Schyntax, instead of using this library directly.

Schyntax exposes the Schedule class.

using Schyntax;

var sch = new Schedule("min(*%2)");

Schedule#Next

Accepts an optional after argument in the form of a DateTime. If no argument is provided, the current time is used.

Returns a DateTime 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 ValidTimeNotFoundException error is thrown, which generally indicates conflicting scheduling criteria (explicitly including and excluding the same day or time).

var nextEventTime = sch.Next();

Schedule#Previous

Same as Previous() 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.

var prevEventTime = sch.Previous(); 

cs-schyntax's People

Contributors

bretcope avatar rossipedia avatar spiralis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.