index.js 699 B

12345678910111213141516171819202122232425
  1. import toDate from "../toDate/index.js";
  2. import requiredArgs from "../_lib/requiredArgs/index.js";
  3. /**
  4. * @name getDay
  5. * @category Weekday Helpers
  6. * @summary Get the day of the week of the given date.
  7. *
  8. * @description
  9. * Get the day of the week of the given date.
  10. *
  11. * @param {Date|Number} date - the given date
  12. * @returns {0|1|2|3|4|5|6} the day of week, 0 represents Sunday
  13. * @throws {TypeError} 1 argument required
  14. *
  15. * @example
  16. * // Which day of the week is 29 February 2012?
  17. * const result = getDay(new Date(2012, 1, 29))
  18. * //=> 3
  19. */
  20. export default function getDay(dirtyDate) {
  21. requiredArgs(1, arguments);
  22. var date = toDate(dirtyDate);
  23. var day = date.getDay();
  24. return day;
  25. }