UNPKG

1.06 kBJavaScriptView Raw
1import { startOfMinute } from "./startOfMinute.js";
2
3/**
4 * @name isSameMinute
5 * @category Minute Helpers
6 * @summary Are the given dates in the same minute (and hour and day)?
7 *
8 * @description
9 * Are the given dates in the same minute (and hour and day)?
10 *
11 * @param laterDate - The first date to check
12 * @param earlierDate - The second date to check
13 *
14 * @returns The dates are in the same minute (and hour and day)
15 *
16 * @example
17 * // Are 4 September 2014 06:30:00 and 4 September 2014 06:30:15 in the same minute?
18 * const result = isSameMinute(
19 * new Date(2014, 8, 4, 6, 30),
20 * new Date(2014, 8, 4, 6, 30, 15)
21 * )
22 * //=> true
23 *
24 * @example
25 * // Are 4 September 2014 06:30:00 and 5 September 2014 06:30:00 in the same minute?
26 * const result = isSameMinute(
27 * new Date(2014, 8, 4, 6, 30),
28 * new Date(2014, 8, 5, 6, 30)
29 * )
30 * //=> false
31 */
32export function isSameMinute(laterDate, earlierDate) {
33 return +startOfMinute(laterDate) === +startOfMinute(earlierDate);
34}
35
36// Fallback for modularized imports:
37export default isSameMinute;