UNPKG

@enonic/mock-xp

Version:

Mock Enonic XP API JavaScript Library

50 lines (49 loc) 1.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LocalDate = void 0; var LocalDate = (function () { function LocalDate(value) { if (typeof value === 'string') { this.date = new Date(value); } else { this.date = value; } } LocalDate.prototype.getYear = function () { return this.date.getFullYear(); }; LocalDate.prototype.getMonthValue = function () { return this.date.getMonth() + 1; }; LocalDate.prototype.getMonth = function () { return LocalDate.months[this.date.getMonth()]; }; LocalDate.prototype.getDayOfMonth = function () { return this.date.getDate(); }; LocalDate.prototype.getDayOfWeek = function () { return LocalDate.daysOfWeek[this.date.getDay()]; }; LocalDate.prototype.getDayOfYear = function () { var start = new Date(this.date.getFullYear(), 0, 0); var diff = this.date.getTime() - start.getTime(); var oneDay = 1000 * 60 * 60 * 24; return Math.floor(diff / oneDay); }; LocalDate.prototype.isLeapYear = function () { var year = this.getYear(); return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0; }; LocalDate.months = [ 'JANUARY', 'FEBRUARY', 'MARCH', 'APRIL', 'MAY', 'JUNE', 'JULY', 'AUGUST', 'SEPTEMBER', 'OCTOBER', 'NOVEMBER', 'DECEMBER' ]; LocalDate.daysOfWeek = [ 'MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY', 'SUNDAY' ]; return LocalDate; }()); exports.LocalDate = LocalDate;