37 lines
689 B
TypeScript
37 lines
689 B
TypeScript
import moment from "moment";
|
|
|
|
const formatIsoDate = (isoDate: string) => {
|
|
const date = new Date(isoDate);
|
|
const monthNames = [
|
|
'Jan',
|
|
'Feb',
|
|
'Mar',
|
|
'Apr',
|
|
'May',
|
|
'Jun',
|
|
'Jul',
|
|
'Aug',
|
|
'Sep',
|
|
'Oct',
|
|
'Nov',
|
|
'Dec'
|
|
];
|
|
const day = date.getDate();
|
|
const month = monthNames[date.getMonth()];
|
|
const year = date.getFullYear();
|
|
return `${day} ${month}, ${year}`;
|
|
};
|
|
|
|
const get5LastYear = () => {
|
|
const last5Years = [];
|
|
for (let i = 0; i < 5; i++) {
|
|
last5Years.push(moment().subtract(i, 'years').format('YYYY'));
|
|
}
|
|
|
|
// console.log('last5Years :', last5Years);
|
|
return last5Years;
|
|
|
|
};
|
|
|
|
export { formatIsoDate, get5LastYear };
|