diff --git a/src/utils.ts b/src/utils.ts new file mode 100644 index 0000000..7d287a6 --- /dev/null +++ b/src/utils.ts @@ -0,0 +1,27 @@ +/** + * Utility functions for common operations + */ + +/** + * Formats a Date object to a readable string (YYYY-MM-DD) + * @param date - The date to format + * @returns Formatted date string + */ +export function formatDate(date: Date): string { + 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}` +} + +/** + * Capitalizes the first letter of a string + * @param str - The string to capitalize + * @returns String with first letter capitalized + */ +export function capitalize(str: string): string { + if (str.length === 0) { + return str + } + return str.charAt(0).toUpperCase() + str.slice(1) +}