import bcrypt from 'bcrypt';

export class Converter {
  static getHashedPassword(password: string) {
    return bcrypt.hashSync(password, 10);
  }

  static comparePassword(rawPassword: string, hashedPassword: string) {
    return bcrypt.compareSync(rawPassword, hashedPassword);
  }

  static formatDateToSqlDate(date: string): string {
    const targetDate = new Date(date);
    const year = targetDate.getUTCFullYear();
    const month = (targetDate.getUTCMonth() + 1).toString().padStart(2, '0');
    const day = (targetDate.getUTCDate()).toString().padStart(2, '0');

    return `${year}-${month}-${day}`;
  }
}