Skip to content

Instantly share code, notes, and snippets.

@danielmascena
Created August 5, 2020 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielmascena/2c3a42a10267e6294f449a4f9d8359b9 to your computer and use it in GitHub Desktop.
Save danielmascena/2c3a42a10267e6294f449a4f9d8359b9 to your computer and use it in GitHub Desktop.
A simple helper method to get the days of week
(function(Date) {
if (new RegExp(Date.name).test(Object.prototype.toString.call(new Date)) && !Date.prototype.getWeekDayString) {
const WEEKDAYS = ["SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY"];
Date.prototype.getWeekDayString = function() {
return WEEKDAYS[this.getDay()];
};
}
})(globalThis && globalThis.Date || (window && window.Date || global && global.Date));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment