https://github.com/doingweb/day-events
Event emitter for daily events like sunrise, sunset, dawn, dusk, etc.
https://github.com/doingweb/day-events
dawn day daytime dusk event-emitter events golden-hour nadir-point night sun sunrise sunset twilight
Last synced: 2 months ago
JSON representation
Event emitter for daily events like sunrise, sunset, dawn, dusk, etc.
- Host: GitHub
- URL: https://github.com/doingweb/day-events
- Owner: doingweb
- Created: 2018-03-25T08:52:45.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-26T02:38:47.000Z (over 7 years ago)
- Last Synced: 2024-07-16T17:59:55.151Z (about 1 year ago)
- Topics: dawn, day, daytime, dusk, event-emitter, events, golden-hour, nadir-point, night, sun, sunrise, sunset, twilight
- Language: JavaScript
- Size: 65.4 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
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](https://github.com/mourner/suncalc#sunlight-times) and documented constants are included.
```js
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()}`);
```