universal-common
Version:
Library that provides useful missing base class library functionality.
120 lines (106 loc) • 2.66 kB
JavaScript
/**
* @file DayOfWeek.js
* @description Defines a static class for representing days of the week as numerical constants.
*/
/**
* A static class that provides numerical constants for the days of the week,
* starting with Sunday as 0 and ending with Saturday as 6.
*
* This class is designed to be used as an enumeration, allowing for clear and
* consistent representation of days in applications.
*
* @example
* import DayOfWeek from './DayOfWeek.js';
*
* console.log(DayOfWeek.MONDAY); // Output: 1
*
* if (someDay === DayOfWeek.FRIDAY) {
* // Do something specific for Friday
* }
*/
export default class DayOfWeek {
/**
* Represents Sunday.
* @private
* @static
* @type {number}
*/
static #SUNDAY = 0;
/**
* Represents Monday.
* @private
* @static
* @type {number}
*/
static #MONDAY = 1;
/**
* Represents Tuesday.
* @private
* @static
* @type {number}
*/
static #TUESDAY = 2;
/**
* Represents Wednesday.
* @private
* @static
* @type {number}
*/
static #WEDNESDAY = 3;
/**
* Represents Thursday.
* @private
* @static
* @type {number}
*/
static #THURSDAY = 4;
/**
* Represents Friday.
* @private
* @static
* @type {number}
*/
static #FRIDAY = 5;
/**
* Represents Saturday.
* @private
* @static
* @type {number}
*/
static #SATURDAY = 6;
/**
* Get the numerical representation for Sunday.
* @returns {number} The value for Sunday (0).
*/
static get SUNDAY() { return this.#SUNDAY; }
/**
* Get the numerical representation for Monday.
* @returns {number} The value for Monday (1).
*/
static get MONDAY() { return this.#MONDAY; }
/**
* Get the numerical representation for Tuesday.
* @returns {number} The value for Tuesday (2).
*/
static get TUESDAY() { return this.#TUESDAY; }
/**
* Get the numerical representation for Wednesday.
* @returns {number} The value for Wednesday (3).
*/
static get WEDNESDAY() { return this.#WEDNESDAY; }
/**
* Get the numerical representation for Thursday.
* @returns {number} The value for Thursday (4).
*/
static get THURSDAY() { return this.#THURSDAY; }
/**
* Get the numerical representation for Friday.
* @returns {number} The value for Friday (5).
*/
static get FRIDAY() { return this.#FRIDAY; }
/**
* Get the numerical representation for Saturday.
* @returns {number} The value for Saturday (6).
*/
static get SATURDAY() { return this.#SATURDAY; }
}