press-pix
Version:
基于 PixUI 的 Press 组件库
36 lines (26 loc) • 615 B
text/typescript
function parseYearMonth(value) {
const { year, month } = getYearAndMonth(value);
return `${year}/${month}`;
}
export const defaultFormatter = (type, value) => {
if (type === 'yearMonth') {
return parseYearMonth(value);
}
return value;
};
export const YEAR_AND_MONTH_AND_DATE = 'yearMonth-day-hour-minute';
export const YEAR_AND_MONTH = 'yearMonth';
export function getYearAndMonth(value) {
const month = value % 12;
const year = parseInt(`${(value - month) / 12}`, 10);
if (!month) {
return {
year: year - 1,
month: 12,
};
}
return {
year,
month,
};
}