You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

35 lines
711 B

const accusativeWeekdays = [
"vasárnap",
"hétfőn",
"kedden",
"szerdán",
"csütörtökön",
"pénteken",
"szombaton",
];
function week(isFuture) {
return (date) => {
const weekday = accusativeWeekdays[date.getDay()];
const prefix = isFuture ? "" : "'múlt' ";
return `${prefix}'${weekday}' p'-kor'`;
};
}
const formatRelativeLocale = {
lastWeek: week(false),
yesterday: "'tegnap' p'-kor'",
today: "'ma' p'-kor'",
tomorrow: "'holnap' p'-kor'",
nextWeek: week(true),
other: "P",
};
export const formatRelative = (token, date) => {
const format = formatRelativeLocale[token];
if (typeof format === "function") {
return format(date);
}
return format;
};