🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

bells

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bells

Bell schedule computation and formatting

0.1.1
latest
Source
npm
Version published
Weekly downloads
4
300%
Maintainers
1
Weekly downloads
 
Created
Source

bells Build Status

This is an npm module that helps with the computation of bell schedules.

Install

npm install --save bells once it is published

Features

  • Awesomeness
  • Store names for certain periods, not necessarily numerical or in order
  • Get the current period
  • Get when the next bell is
  • Have bells not associated with a specific period
  • Guess the bell schedule for a specific day based on a given set of criteria

API

Times are passed around as instances of Moment().

When an argument is a time, Bells attempts to parse it as a HH:mm time (24hr time). A date argument must be given in a format specified here.

Bells(bellScheduleRepresentation)

Create a Bells object. See below for the layout of bellScheduleRepresentation.

var Bells = require('bells');

// Steinbrenner High School of Lutz, FL's normal bell schedule
var schedule = Bells({
	periods: {
		'1': ['7:33', '8:23'], // [start-time, end-time]
		'2': ['8:29', '9:24'], // Where time between 00:00 and 23:59
		'3': ['9:30', '10:20'],
		'4 (1st lunch)': ['10:26', '11:16'],
		'5 (2nd lunch)': ['11:22', '12:12'],
		'6 (3rd lunch)': ['12:18', '13:08'],
		'7': ['13:14', '14:04'],
		'8': ['14:10', '15:00'],
	},
	other: [
		'7:15',
		'7:25',
	],
});
// => Object

Bells#currentPeriod([now])

Get the name of the current period, or null. See above for more info about time parameters.

schedule.currentPeriod('13:00');
// => '6 (3rd lunch)'
schedule.currentPeriod('14:15');
// => '8'
schedule.currentPeriod('16:00');
// => null

Bells#nextBell([now])

Get the time of the next bell, as a Moment(). See above for more info about time parameters.

schedule.nextBell('7:10');
// => '07:15'
schedule.nextBell('8:23');
// => '08:29'
schedule.nextBell('16:00');
// => null

Bells#periods()

Get all class periods passed to the initializer.

schedule.periods();
/* => {
	'1': ['7:33', '8:23'],
	...
	'8': ['14:10', '15:00'],
} */

Bells.allBells()

Get all bells in the schedule, sorted in ascending order.

schedule.allBells()
/* => [
	'7:15',
	'7:25',
	...
	'15:00',
] */

Bells.Predictor(criteria)

Create a Predictor object. See below for the layout of criteria.

Note that a predictor only associates a string to a specific set of criteria. It does not associate a Bells object to that string.

var Bells = require('bells');

var Predictor = Bells.Predictor({
	// 'default' is the fallback bell schedule.
	// This is returned when there is no other bell schedule specified for a day.
	'default': 'Normal Day',

	// 'none' is interpreted to mean there is no school.
	// 0&6 mean that this applies on those days of the week, where
	// 	0 is Sunday and 6 is Saturday.
	// SMTWTFS
	// 0123456
	'0': 'none',
	'6': 'none',

	// This applies on 4/18/14.
	// A specific date overrides any day-of-week selector and the 'default'.
	// The dates *MUST* be zero-padded or the predictor won't find it
	'04/18/2014': 'none',

	'04/17/2014': 'FCAT',
	'04/22/2014': 'FCAT',
	'04/23/2014': 'FCAT',

	'04/14/2014': 'FCAT - Monday',
});

// A possible future implementation
/*var Predictor = Bells.Predictor({
	// 'none' is interpreted to mean there is no school.
	// [0, 6] means that this applies on those days of the week, where
	// 	0 is Sunday and 6 is Saturday.
	'none': [0, 6],

	// 'default' is the fallback bell schedule.
	// There can only be one default.
	'Normal Day': 'default',

	// This applies when the day equals 1 (Monday).
	// A specific day of the week gets higher priority than 'default', but lower
	// 	than a specific date.
	'Monday': 1,

	// This applies on 4/14/14 and 4/17/14.
	// A specific date overrides any day-of-week selector or the 'default'.
	'FCAT': ['4/17/2014', '4/22/2014', '4/23/2014'],

	// You can also specify a string with a date instead of an array of strings
	'FCAT - Monday': '4/14/2014',
});*/
// => Object

Predictor#predict([date])

Predict the bell schedule for a certain date, or today if omitted. (The date must be a full month/day/year, in any format guessable by Moment.)

Predictor.predict('2014-04-15'); // normal Tuesday
// => 'Normal Day'
Predictor.predict('2014-04-21'); // normal Monday
// => 'Monday'
Predictor.predict('2014-04-14'); // FCAT Monday
// => 'FCAT - Monday'
Predictor.predict('2014-04-19'); // Saturday
// => 'none'

FAQs

Package last updated on 20 May 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts