From 8f97095fbc2859e8ec5e4d92515d8e3a1d82b026 Mon Sep 17 00:00:00 2001 From: supmiku39 Date: Mon, 6 Apr 2020 01:09:37 +0900 Subject: [PATCH] forgot to build --- dist/utils/FullDate.d.ts | 14 ++++++--- dist/utils/FullDate.js | 64 ++++++++++++++++++++++++++++++++-------- 2 files changed, 62 insertions(+), 16 deletions(-) diff --git a/dist/utils/FullDate.d.ts b/dist/utils/FullDate.d.ts index 9605a76..914e2b1 100644 --- a/dist/utils/FullDate.d.ts +++ b/dist/utils/FullDate.d.ts @@ -1,10 +1,16 @@ export declare class FullDate { - private date; + private _date; constructor(...argv: any); toString(): string; toJSON(): string; valueOf(): number; - getFullYear(): number; - getMonth(): number; - getDate(): number; + get date(): Date; + get year(): number; + get month(): number; + get day(): number; + get dayOfWeek(): number; + set year(val: number); + set month(val: number); + set day(val: number); + advance(period: number): FullDate; } diff --git a/dist/utils/FullDate.js b/dist/utils/FullDate.js index 4538f55..27396d3 100644 --- a/dist/utils/FullDate.js +++ b/dist/utils/FullDate.js @@ -6,7 +6,7 @@ var FullDate = /** @class */ (function () { for (var _i = 0; _i < arguments.length; _i++) { argv[_i] = arguments[_i]; } - this.date = (function () { + this._date = (function () { var _a; if (argv.length == 1) { var arg = argv[0]; @@ -28,7 +28,7 @@ var FullDate = /** @class */ (function () { })(); } FullDate.prototype.toString = function () { - var d = this.date; + var d = this._date; var f = function (s) { return ('0' + s).slice(-2); }; return d.getFullYear() + "-" + f(d.getMonth() + 1) + "-" + f(d.getDate()); }; @@ -36,17 +36,57 @@ var FullDate = /** @class */ (function () { return this.toString(); }; FullDate.prototype.valueOf = function () { - return new Date(this.date).setHours(0, 0, 0, 0); + return new Date(this._date).setHours(0, 0, 0, 0); }; - // prop - FullDate.prototype.getFullYear = function () { - return this.date.getFullYear(); - }; - FullDate.prototype.getMonth = function () { - return this.date.getMonth() + 1; - }; - FullDate.prototype.getDate = function () { - return this.date.getDate(); + Object.defineProperty(FullDate.prototype, "date", { + // getter + get: function () { + return new Date(this._date); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(FullDate.prototype, "year", { + get: function () { + return this._date.getFullYear(); + }, + // setter + set: function (val) { + this._date.setFullYear(val); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(FullDate.prototype, "month", { + get: function () { + return this._date.getMonth() + 1; + }, + set: function (val) { + this._date.setMonth(val - 1); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(FullDate.prototype, "day", { + get: function () { + return this._date.getDate(); + }, + set: function (val) { + this._date.setDate(val); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(FullDate.prototype, "dayOfWeek", { + get: function () { + return this._date.getDay(); + }, + enumerable: true, + configurable: true + }); + // func + FullDate.prototype.advance = function (period) { + return new FullDate(this._date.valueOf() + period * 86400e3); }; return FullDate; }());