type DateParts = {day: string; month: string; year: string; hour: string; minute: string; second: string}
export class SimpleDate{
  private date:Date;
  public parts: DateParts;
  


  constructor(date?: Date | undefined){
    this.date = date ?? new Date()
    this.parts = {
      day: String(this.date.getDate()).padStart(2,"0"),
      month: String(this.date.getMonth() + 1).padStart(2,"0"),
      year: String(this.date.getFullYear()),
      hour: String(this.date.getHours()).padStart(2, "0"),
      minute: String(this.date.getMinutes()).padStart(2,"0"),
      second: String(this.date.getSeconds()).padStart(2, "0"),
    }
  }

  public getDate(){
    return this.date
  }

  public static now(){
    return new this()
  }

  public format(formatString: "YYYY-MM-DD" | "DD.MM.YYYY"){
    switch(formatString){
      case "YYYY-MM-DD":
        return `${this.parts.year}-${this.parts.month}-${this.parts.day}`
      case "DD.MM.YYYY":
        return `${this.parts.day}.${this.parts.month}.${this.parts.year}`
    }
  }

  public toISOString(){
    return `${this.parts.year}-${this.parts.month}-${this.parts.day} ${this.parts.hour}:${this.parts.minute}:${this.parts.second}`
  }
}