getDay.js 650 B

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