Archived
1
0
Fork 0

forgot to build

This commit is contained in:
supmiku39 2020-04-06 01:09:37 +09:00
parent 71c9334dcd
commit 8f97095fbc
2 changed files with 62 additions and 16 deletions

View file

@ -1,10 +1,16 @@
export declare class FullDate { export declare class FullDate {
private date; private _date;
constructor(...argv: any); constructor(...argv: any);
toString(): string; toString(): string;
toJSON(): string; toJSON(): string;
valueOf(): number; valueOf(): number;
getFullYear(): number; get date(): Date;
getMonth(): number; get year(): number;
getDate(): 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;
} }

View file

@ -6,7 +6,7 @@ var FullDate = /** @class */ (function () {
for (var _i = 0; _i < arguments.length; _i++) { for (var _i = 0; _i < arguments.length; _i++) {
argv[_i] = arguments[_i]; argv[_i] = arguments[_i];
} }
this.date = (function () { this._date = (function () {
var _a; var _a;
if (argv.length == 1) { if (argv.length == 1) {
var arg = argv[0]; var arg = argv[0];
@ -28,7 +28,7 @@ var FullDate = /** @class */ (function () {
})(); })();
} }
FullDate.prototype.toString = function () { FullDate.prototype.toString = function () {
var d = this.date; var d = this._date;
var f = function (s) { return ('0' + s).slice(-2); }; var f = function (s) { return ('0' + s).slice(-2); };
return d.getFullYear() + "-" + f(d.getMonth() + 1) + "-" + f(d.getDate()); return d.getFullYear() + "-" + f(d.getMonth() + 1) + "-" + f(d.getDate());
}; };
@ -36,17 +36,57 @@ var FullDate = /** @class */ (function () {
return this.toString(); return this.toString();
}; };
FullDate.prototype.valueOf = function () { 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 Object.defineProperty(FullDate.prototype, "date", {
FullDate.prototype.getFullYear = function () { // getter
return this.date.getFullYear(); get: function () {
}; return new Date(this._date);
FullDate.prototype.getMonth = function () { },
return this.date.getMonth() + 1; enumerable: true,
}; configurable: true
FullDate.prototype.getDate = function () { });
return this.date.getDate(); 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; return FullDate;
}()); }());