UNPKG

633 BJavaScriptView Raw
1import { toDate } from "./toDate.js";
2
3/**
4 * The {@link getHours} function options.
5 */
6
7/**
8 * @name getHours
9 * @category Hour Helpers
10 * @summary Get the hours of the given date.
11 *
12 * @description
13 * Get the hours of the given date.
14 *
15 * @param date - The given date
16 * @param options - An object with options
17 *
18 * @returns The hours
19 *
20 * @example
21 * // Get the hours of 29 February 2012 11:45:00:
22 * const result = getHours(new Date(2012, 1, 29, 11, 45))
23 * //=> 11
24 */
25export function getHours(date, options) {
26 return toDate(date, options?.in).getHours();
27}
28
29// Fallback for modularized imports:
30export default getHours;