getDay.js 755 B

12345678910111213141516171819202122232425262728
  1. "use strict";
  2. exports.getDay = getDay;
  3. var _index = require("./toDate.js");
  4. /**
  5. * @name getDay
  6. * @category Weekday Helpers
  7. * @summary Get the day of the week of the given date.
  8. *
  9. * @description
  10. * Get the day of the week of the given date.
  11. *
  12. * @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).
  13. *
  14. * @param date - The given date
  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. function getDay(date) {
  24. const _date = (0, _index.toDate)(date);
  25. const day = _date.getDay();
  26. return day;
  27. }