Giter VIP home page Giter VIP logo

schedule-checker's Introduction

schedule-checker

A module for specifying a weekly schedule of sessions and checking if a given time is within a session or not.

Session definition file:

The session definition file is YAML.

Here's an example schedule file that sets 8am-5pm sessions every day except for Friday, which ends early at 2pm.

# Timezone specifies if the sessions are specified in UTC or local.
# => valid values: "utc" or "local"
# => If not present, then "utc".
timezone: utc

# Define as many weekly sessions as you want.  Times are 24-hour time.
# Overlapping sessions are invalid and will raise an error.
# Sessions can span multiple days.
sessions:
- Mon/08:00:00-Mon/17:00:00
- Tue/08:00:00-Tue/17:00:00
- Wed/08:00:00-Wed/17:00:00
- Thu/08:00:00-Thu/17:00:00
- Fri/08:00:00-Fri/14:00:00
# (You can also specify full-length day names if you like (e.g. "Friday/08:00:00"))

To specify a non-stop session, this is all you need:

sessions:
- non-stop
# "nonstop" without hyphen is also acceptable

How to load and use that file:

require 'schedule-checker'
schedule = ScheduleChecker.parse_schedule_file(filename)

schedule.in_a_session?(Time.now)   #utc or local times both work

schedule-checker's People

Contributors

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