Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including node-red-contrib-time-range-switch with all npm packages installed. Try it out:

var nodeRedContribTimeRangeSwitch = require("node-red-contrib-time-range-switch")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

node-red-contrib-time-range-switch v0.6.3

Time Range Switch

A simple Node-RED node that routes messages depending on the time. If the current time falls within the range specified in the node configuration, the message is routed to output 1. Otherwise the message is routed to output 2.


Change directory to your node red installation:

$ npm install node-red-contrib-time-range-switch


The times can be a 24 hour time or a suncalc event:

00:00 ... 23:5924hr time
sunrisesunrise (top edge of the sun appears on the horizon)
sunriseEndsunrise ends (bottom edge of the sun touches the horizon)
goldenHourEndmorning golden hour (soft light, best time for photography) ends
solarNoonsolar noon (sun is in the highest position)
goldenHourevening golden hour starts
sunsetStartsunset starts (bottom edge of the sun touches the horizon)
sunsetsunset (sun disappears below the horizon, evening civil twilight starts)
duskdusk (evening nautical twilight starts)
nauticalDusknautical dusk (evening astronomical twilight starts)
nightnight starts (dark enough for astronomical observations)
nadirnadir (darkest moment of the night, sun is in the lowest position)
nightEndnight ends (morning astronomical twilight starts)
nauticalDawnnautical dawn (morning nautical twilight starts)
dawndawn (morning nautical twilight ends, morning civil twilight starts)


The start and end time can have an offset. This is specified in minutes:

  • -ve number brings the time forward. E.g. if the time is dusk and offset is -60, the start time will be 60 minutes before dusk.
  • +ve number delays the time by the specified number of minutes
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free