import { getWeekdays } from '../utils';
import { WEEKDAYS_SHORT } from '../calendar-date';
/**
 * Calendar view generator abstract class.
 */
export class CalendarViewGenerator {
  constructor() {
    this.weekdays = getWeekdays();
  }
  /**
   * Get weekday names.
   *
   * @returns {string[]} - The weekday strings
   */
  getWeekdayNames() {
    return WEEKDAYS_SHORT;
  }
  /**
   * Generate calendar dates
   *
   * @param {CalendarPeriod} period - The calendar period
   * @returns {Date[]} - The date result
   */
  generateDates(period) {
    const cursor = period.startDate.toDate();
    const dates = [];
    for (let i = 0; i < period.count; i++) {
      dates.push(new Date(cursor));
      cursor.setDate(cursor.getDate() + 1);
    }
    return dates;
  }
  /**
   * Generate calendar head
   *
   * @returns {string[]} - The data of week head
   */
  generateWeekHead() {
    return this.weekdays.map((day) => this.getWeekdayNames()[day]);
  }
}
