Giter Club home page Giter Club logo

chronic_between's Introduction

Chronic Between

A simple Ruby natural language parser for date and time ranges. (For example, Mon-Fri 09:00-16:30, etc.) Returns a boolean result.

Several date and time ranges can be supplied with matching patterns being separated by a comma.

Installation

$ sudo gem sources -a http://gemcutter.org
$ sudo gem install chronic_between

Usage

>> s = 'Mon-Fri 9:00-16:30, Saturday, Sunday'
>> c = ChronicBetween.new(s)

>> DateTime.now      
=> #<DateTime: 2011-03-26T16:54:40+00:00

>> c.within? DateTime.now
=> true

>> c.within? DateTime.parse("28-Mar-2011 14:33")
=> true

>> c.within? DateTime.parse("28-Mar-2011 08:33")
=> false

Examples of parse-able strings:

  • ‘Mon-Fri 9:00-16:30’

  • ‘saturday’

  • ‘12:00-13:00’

  • ‘Sat,Sun’

  • ‘Mon-Fri 9:00-16:30, Saturday, Sunday’

  • ‘Mon-Fri 9:00-16:30, Saturday, 10:15-10:45’

  • ‘Sat 18:15-21:40’

  • ‘Mon-Wed’

  • ‘Mon-Fri 9:00 to 16:30’

  • ‘9:00-16:30 Mon-Fri’

  • ‘9:00 to 16:30 Mon-Fri’

  • ‘3:45 to 5:15’

  • ‘Mon 3:45 to 5:15’

  • ‘3:45-5:15 Mon’

  • ‘3:45 to 5:15 Mon’

  • ‘after 6pm’

  • ‘before 9pm’

  • ‘April 2nd - April 5th 12:00-14:00’

  • ‘April 5th - April 9th’

  • ‘April 5th’

  • ‘not before 6pm’

  • ‘except after 6pm’

  • ‘Sunday, after 6pm’

  • ‘Saturday, not after 6pm’

chronic_between's People

Contributors

wbond 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.