27 lines
808 B
TypeScript
27 lines
808 B
TypeScript
// Utility functions
|
|
|
|
/**
|
|
* Makes the first character of a string uppercase.
|
|
* @param str - The string to transform.
|
|
* @returns The transformed string.
|
|
*/
|
|
export function makeFirstCharUpper(str: string): string {
|
|
if (!str) return "";
|
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
}
|
|
|
|
/**
|
|
* Formats a date string into a more readable format.
|
|
* @param dateString - The date string to format.
|
|
* @returns The formatted date string.
|
|
*/
|
|
export function formatDate(dateString: string): string {
|
|
if (!dateString) return "";
|
|
const date = new Date(dateString);
|
|
if (Number.isNaN(date.getTime())) return "";
|
|
const year = date.getFullYear();
|
|
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
const day = String(date.getDate()).padStart(2, "0");
|
|
return `${year}-${month}-${day}`;
|
|
}
|