const year = String(new Date(createdAt!).getFullYear());
const month = String(new Date(createdAt!).getMonth());
const date = String(new Date(createdAt!).getDate());
abstract class Constr {
protected year: string;
protected month: string;
protected time: string;
constructor({ year, month }: Partial<CreateAt>) {
this.year = year!;
this.month = month!;
this.time = `${year}. ${month}.`;
}
}
class Time extends Constr {
public finalDate: string;
protected date: string;
constructor({ year, month, date }: Partial<CreateAt>) {
super({ year, month });
this.date = date!;
this.finalDate = `${this.time} ${this.date}`;
}
}
const times = new Time({ year, month, date });
console.log(times.finalDate);
맘에 드는군
댓글 0