fix: Display year when date is outside of current year (#567)

This commit is contained in:
Yu Inoue
2023-12-20 12:26:01 +01:00
committed by GitHub
parent fbd1b28312
commit db9e877506
21 changed files with 60 additions and 4 deletions
+16 -2
View File
@@ -4,6 +4,8 @@ import PropTypes from 'prop-types';
import classNames from 'classnames';
import { useTranslation } from 'react-i18next';
import getDateFormat from '../../utils/get-date-format';
import styles from './DueDate.module.scss';
const SIZES = {
@@ -12,15 +14,27 @@ const SIZES = {
MEDIUM: 'medium',
};
const FORMATS = {
const LONG_DATE_FORMAT_BY_SIZE = {
tiny: 'longDate',
small: 'longDate',
medium: 'longDateTime',
};
const FULL_DATE_FORMAT_BY_SIZE = {
tiny: 'fullDate',
small: 'fullDate',
medium: 'fullDateTime',
};
const DueDate = React.memo(({ value, size, isDisabled, onClick }) => {
const [t] = useTranslation();
const dateFormat = getDateFormat(
value,
LONG_DATE_FORMAT_BY_SIZE[size],
FULL_DATE_FORMAT_BY_SIZE[size],
);
const contentNode = (
<span
className={classNames(
@@ -29,7 +43,7 @@ const DueDate = React.memo(({ value, size, isDisabled, onClick }) => {
onClick && styles.wrapperHoverable,
)}
>
{t(`format:${FORMATS[size]}`, {
{t(`format:${dateFormat}`, {
value,
postProcess: 'formatDate',
})}