15 lines
487 B
TypeScript
15 lines
487 B
TypeScript
|
// Format the date to a string
|
||
|
function formatDate(date: Date): string {
|
||
|
const options: Intl.DateTimeFormatOptions = {year: 'numeric', month: 'short', day: 'numeric'};
|
||
|
|
||
|
return new Date(date).toLocaleDateString(undefined, options);
|
||
|
}
|
||
|
// Capitalize the first letter
|
||
|
function capitalize(str:string): string {
|
||
|
if ( typeof str !== 'string' || str.length === 0 ) {
|
||
|
return str;
|
||
|
}
|
||
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
||
|
}
|
||
|
|
||
|
export { formatDate, capitalize };
|