mirror of
https://github.com/samiyev/agentic-test.git
synced 2025-12-27 23:06:50 +05:00
feat: add utils.ts with formatDate and capitalize functions
- Add formatDate(date: Date): string function - Add capitalize(str: string): string function - Include JSDoc documentation Closes #2
This commit is contained in:
27
src/utils.ts
Normal file
27
src/utils.ts
Normal file
@@ -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)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user