Nifty ToU (Time of Use)

Nifty ToU is a delightful little JavaScript library for working with time-of-use based tariffs. It aims to be easy to use, reliable, and without any external dependencies.

A central class in Nifty ToU is TemporalRangesTariff, that defines a set of tariff values with a set of time-based constraints. The implication is that the tariff values apply only when all the time-based constraints are valid.

The time-based constraints are encoded as IntRange objects, that are integer ranges with minimum and maximum values that define the bounds of the constraint. The supported time-based constraints are:

Constraint Example Bounds
month range January - March 1 - 12 (January - December, inclusive)
day of month range 1 - 31 1 - 31 (inclusive)
day of week range Monday - Friday 1 - 7 (Monday - Sunday, inclusive)
minute of day range 00:00 - 08:30 0 - 1440 (inclusive minimum, exclusive maximum)

API Documentation

See the API docs for more information.

Source code

The source code is available on GitHub.