I have a helper that formats dates, and I saw that you can use a helper in code if you formate the exports properly. So I was just wondering is that bad practices, and is there something better?
export function format_date([date, format]) {
if(date == undefined || date.length == 0){
return ""
}
let d = new Date(date);
let output_format = {};
if(format.y == 1){
output_format.year = "numeric";
}
if(format.m == 1){
output_format.month = "2-digit";
}
if(format.d == 1){
output_format.day = "numeric";
}
if(format.h == 1){
output_format.hour = "numeric";
}
if(format.h12 == 1){
output_format.hour12 = true;
}
return d.toLocaleDateString('en-us', output_format);
}
export default helper(format_date);```