param { string | Date } date param { string } fallback param { string } locale export function formatDate ( date , includeTime = false , fallback = '' , locale = 'nb-NO' ) { let options = { weekday : 'long' , year : 'numeric' , month : 'short' , day : 'numeric' } ; if ( includeTime ) { options = { ... options , hour : '2-digit' , minute : '2-digit' } ; } if ( ! date ) return fallback ; return ( typeof date === 'string' ? new Date ( date ) : date ) . toLocaleString ( locale , options ) ; }