/* eslint-disable eslint-comments/no-unlimited-disable */ /* eslint-disable */ // @ts-nocheck import { normalizeDates } from '../_lib/normalizeDates/index.ts'; import { startOfHour } from '../startOfHour/index.ts'; import type { ContextOptions, DateArg } from '../types.ts'; /** * The {@link isSameHour} function options. */ export interface IsSameHourOptions extends ContextOptions {} /** * @name isSameHour * @category Hour Helpers * @summary Are the given dates in the same hour (and same day)? * * @description * Are the given dates in the same hour (and same day)? * * @param dateLeft - The first date to check * @param dateRight - The second date to check * @param options - An object with options * * @returns The dates are in the same hour (and same day) * * @example * // Are 4 September 2014 06:00:00 and 4 September 06:30:00 in the same hour? * const result = isSameHour(new Date(2014, 8, 4, 6, 0), new Date(2014, 8, 4, 6, 30)) * //=> true * * @example * // Are 4 September 2014 06:00:00 and 5 September 06:00:00 in the same hour? * const result = isSameHour(new Date(2014, 8, 4, 6, 0), new Date(2014, 8, 5, 6, 0)) * //=> false */ export function isSameHour( dateLeft: DateArg & {}, dateRight: DateArg & {}, options?: IsSameHourOptions | undefined, ): boolean { const [dateLeft_, dateRight_] = normalizeDates(options?.in, dateLeft, dateRight); return +startOfHour(dateLeft_) === +startOfHour(dateRight_); } /* eslint-enable */