Example #1
0
export const humanDate = (date: Date): string => {
  if (isToday(date)) {
    return 'Today';
  }
  if (isYesterday(date)) {
    return 'Yesterday';
  }

  return isSameYear(new Date(date), new Date()) ? shortDate(date) : longDate(date);
};
  render() {
    const {locale: {locale}, monthDate, today, rows, rowHeight, showOverlay, style, theme} = this.props;
    const dateFormat = isSameYear(monthDate, today) ? 'MMMM' : 'MMMM YYYY';

    return (
      <div className={styles.root} style={{...style, lineHeight: `${rowHeight}px`}}>
  				<div className={styles.rows}>
  					{this.renderRows()}
  					{showOverlay &&
  						<label
                className={classNames(styles.label, {
                  [styles.partialFirstRow]: rows[0].length !== 7,
                })}
                style={{backgroundColor: theme.overlayColor}}
              >
                <span>{format(monthDate, dateFormat, {locale})}</span>
              </label>
  					}
  				</div>
  			</div>
    );
  }