day-events
v1.0.1
Published
Event emitter for daily events like sunrise, sunset, dawn, dusk, etc.
Readme
Day Events
Event emitter for daily events like sunrise, sunset, dawn, dusk, etc.
Usage
DayEvents is an EventEmitter that will emit events as they happen during the day, in real time. The events come from the SunCalc library and documented constants are included with the plugin.
const {
DayEvents,
eventNames: { SUNRISE, SUNSET }
} = require('day-events');
let latitude = 45.5231;
let longitude = -122.6765;
let today = new DayEvents(latitude, longitude);
today.on(SUNRISE, () => console.log('Good morning!'));
today.on(SUNSET, () => console.log('Good evening!'));
let eventTimes = today.getTimes();
console.log(`Sunset is at ${eventTimes[SUNSET].toString()}`);