@technobuddha/library
Version:
A large library of useful functions
26 lines (25 loc) • 1.12 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDayOfWeek = void 0;
var constants_1 = require("../constants");
var modulo_1 = __importDefault(require("../modulo"));
/**
* Determine the day of the week for a specific date
*
* @param input The date
* @param __namedParameters see {@link Options}
* @default UTC false
* @default startOfWeek Monday
* @returns The date value for midnight on the first day of the specified year
*/
function getDayOfWeek(input, _a) {
var _b = _a === void 0 ? {} : _a, _c = _b.UTC, UTC = _c === void 0 ? false : _c, _d = _b.startOfWeek, startOfWeek = _d === void 0 ? constants_1.day.sunday : _d;
if (UTC)
return modulo_1.default(input.getUTCDay() + constants_1.daysPerWeek - startOfWeek, constants_1.daysPerWeek);
return modulo_1.default(input.getDay() + constants_1.daysPerWeek - startOfWeek, constants_1.daysPerWeek);
}
exports.getDayOfWeek = getDayOfWeek;
exports.default = getDayOfWeek;