UNPKG

nhb-toolbox

Version:

A versatile collection of smart, efficient, and reusable utility functions, classes and types for everyday development needs.

42 lines (41 loc) 1.75 kB
import type { $Chronos, DayPart, DayPartConfig } from '../types'; declare module '../Chronos' { interface Chronos { /** * @instance Returns the part of day (`'midnight', 'lateNight', 'night', 'morning', 'afternoon', 'evening'`) based on the current hour. * * *Supports both normal and wraparound (overnight) ranges.* * * @param config - Optional custom hour ranges for each part of day. * Each range must be a tuple of strings as `[startHour, endHour]` in 24-hour format (e.g., `['06', '11']`). * Supports wraparound ranges like `['22', '04']` that cross midnight. * * **Default Ranges:** * - night: ['21', '23'] * - midnight: ['00', '01'] * - lateNight: ['02', '04'] * - morning: ['05', '11'] * - afternoon: ['12', '16'] * - evening: ['17', '20'] * * @returns The current part of the day as a string. * * @example * chronosInstance.getPartOfDay(); // e.g., 'morning' * * @example * // Example with custom ranges * chronosInstance.getPartOfDay({ * night: ['22', '04'], * morning: ['05', '11'], * afternoon: ['12', '16'], * evening: ['17', '21'], * lateNight: ['01', '03'], * midnight: ['00', '00'], * }); */ getPartOfDay(config?: Partial<DayPartConfig>): DayPart; } } /** * Plugin to inject `getPartOfDay` method */ export declare const dayPartPlugin: ($Chronos: $Chronos) => void;