getHours.js 633 B

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