differenceInHours.d.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. import type { RoundingOptions } from "./types.js";
  2. /**
  3. * The {@link differenceInHours} function options.
  4. */
  5. export interface DifferenceInHoursOptions extends RoundingOptions {}
  6. /**
  7. * @name differenceInHours
  8. * @category Hour Helpers
  9. * @summary Get the number of hours between the given dates.
  10. *
  11. * @description
  12. * Get the number of hours between the given dates.
  13. *
  14. * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
  15. *
  16. * @param dateLeft - The later date
  17. * @param dateRight - The earlier date
  18. * @param options - An object with options.
  19. *
  20. * @returns The number of hours
  21. *
  22. * @example
  23. * // How many hours are between 2 July 2014 06:50:00 and 2 July 2014 19:00:00?
  24. * const result = differenceInHours(
  25. * new Date(2014, 6, 2, 19, 0),
  26. * new Date(2014, 6, 2, 6, 50)
  27. * )
  28. * //=> 12
  29. */
  30. export declare function differenceInHours<DateType extends Date>(
  31. dateLeft: DateType | number | string,
  32. dateRight: DateType | number | string,
  33. options?: DifferenceInHoursOptions,
  34. ): number;