Archetype: Node.js package
dayphase determines the dayphase based on hour boundaries. It allows flexible time segmentation for different cultural or system-defined day phases.
npm install dayphase
import dayphase from 'dayphase';
console.log(dayphase([4, 17, 21], 6)); // ➝ 1 (Day Phase)
console.log(dayphase([4, 17, 21], 18)); // ➝ 2 (Evening Phase)
console.log(dayphase([4, 17, 21], 22)); // ➝ 0 (Night Phase)
console.log(dayphase([4, 17, 21], 2)); // ➝ 0 (Night Phase, before first phase)
Parameter | Type | Description |
---|---|---|
phases |
number[] |
(Required) Ordered array of hour values (0-24) defining phase boundaries. |
hour |
number |
(Optional) Hour of the day (0-24). Defaults to new Date().getHours() . |
Type | Description |
---|---|
number |
The index of the current time phase based on the phases array. |
This package is part of my highsociety meta suite:
https://github.com/alexstevovich/highsociety-node - Prose, linguistic, time, and cultural string formatting.
https://github.com/alexstevovich/wellwish-node - Outputs a nuanced well-wishing phrase based on English cultural norms.
https://github.com/alexstevovich/dayphase-node
Licensed under the Apache License 2.0.