Answer the question
In order to leave comments, you need to log in
Error while inheriting class (this is not a X object). How to fix?
Actually, I made this class:
class trueDate extends Date {
constructor(date: string) {
super(date)
}
getFixDay() {
var day = this.getDay()
return day === 0 ? 7 : day
}
addDate(date: number) {
this.setTime(this.getTime() + date * 86400)
}
}
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var trueDate = (function (_super) {
__extends(trueDate, _super);
function trueDate(date) {
_super.call(this, date);
}
trueDate.prototype.getFixDay = function () {
var day = this.getDay();
return day === 0 ? 7 : day;
};
trueDate.prototype.addDate = function (date) {
this.setTime(this.getTime() + date * 86400);
};
return trueDate;
})(Date);
var trueDateObj = new Date("строка-с-датой")
class trueDate extends Date {
constructor(date: string) {
super(date)
}
getDay(): number {
var day = super.getDay()
return day === 0 ? 7 : day
}
addDate(date: number) {
super.setTime(super.getTime() + date * 86400)
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question