import classnames from 'classnames' import dayjs, { Dayjs } from 'dayjs' import React from 'react' import { Picker, Text, View } from '@tarojs/components' import { AtCalendarControllerProps, AtCalendarControllerState } from '../../../../types/calendar' export default class AtCalendarController extends React.Component< AtCalendarControllerProps, AtCalendarControllerState > { public render(): JSX.Element { const { generateDate, minDate, maxDate, monthFormat, hideArrow } = this.props const dayjsDate: Dayjs = dayjs(generateDate) const dayjsMinDate: Dayjs | boolean = !!minDate && dayjs(minDate) const dayjsMaxDate: Dayjs | boolean = !!maxDate && dayjs(maxDate) const isMinMonth: boolean = dayjsMinDate && dayjsMinDate.startOf('month').isSame(dayjsDate) const isMaxMonth: boolean = dayjsMaxDate && dayjsMaxDate.startOf('month').isSame(dayjsDate) const minDateValue: string = dayjsMinDate ? dayjsMinDate.format('YYYY-MM') : '' const maxDateValue: string = dayjsMaxDate ? dayjsMaxDate.format('YYYY-MM') : '' return ( {hideArrow ? null : ( )} {dayjsDate.format(monthFormat)} {hideArrow ? null : ( )} ) } }