startOfISOWeek.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { startOfWeek } from "./startOfWeek.js";
  2. /**
  3. * The {@link startOfISOWeek} function options.
  4. */
  5. /**
  6. * @name startOfISOWeek
  7. * @category ISO Week Helpers
  8. * @summary Return the start of an ISO week for the given date.
  9. *
  10. * @description
  11. * Return the start of an ISO week for the given date.
  12. * The result will be in the local timezone.
  13. *
  14. * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
  15. *
  16. * @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).
  17. * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
  18. *
  19. * @param date - The original date
  20. * @param options - An object with options
  21. *
  22. * @returns The start of an ISO week
  23. *
  24. * @example
  25. * // The start of an ISO week for 2 September 2014 11:55:00:
  26. * const result = startOfISOWeek(new Date(2014, 8, 2, 11, 55, 0))
  27. * //=> Mon Sep 01 2014 00:00:00
  28. */
  29. export function startOfISOWeek(date, options) {
  30. return startOfWeek(date, { ...options, weekStartsOn: 1 });
  31. }
  32. // Fallback for modularized imports:
  33. export default startOfISOWeek;