import React, {Component} from 'react'; import moment from "moment"; export default class Calendar extends Component { state={ current:moment(), }; componentDidMount() { moment.locale('ru', { week : { dow:1 } }); } render() { const {doctor,setAppointmentShedule} = this.props const {current} = this.state const daysArray = [] for (let x=1; x <= current.daysInMonth();x++){ daysArray.push(current.date(x).format('YYYY-MM-DD')) } const prevMonth = moment(current).subtract(1,'months') const startDay = current.startOf('month').day() === 0 ? 7 : current.startOf('month').day() for (let x=1; x < startDay ;x++){ daysArray.unshift(prevMonth.endOf('month').subtract(x-1,'days').format('YYYY-MM-DD')) } return (
{el}
))}