(date: Date, format: string)
| 44 | } |
| 45 | |
| 46 | function formatDate(date: Date, format: string): string { |
| 47 | const year = date.getFullYear() |
| 48 | const month = String(date.getMonth() + 1).padStart(2, '0') |
| 49 | const day = String(date.getDate()).padStart(2, '0') |
| 50 | |
| 51 | if (format === 'yyyy-MM-dd') { |
| 52 | return `${year}-${month}-${day}` |
| 53 | } |
| 54 | if (format === 'MMMM d') { |
| 55 | const monthNames = [ |
| 56 | 'January', |
| 57 | 'February', |
| 58 | 'March', |
| 59 | 'April', |
| 60 | 'May', |
| 61 | 'June', |
| 62 | 'July', |
| 63 | 'August', |
| 64 | 'September', |
| 65 | 'October', |
| 66 | 'November', |
| 67 | 'December', |
| 68 | ] |
| 69 | return `${monthNames[date.getMonth()]} ${date.getDate()}` |
| 70 | } |
| 71 | return date.toISOString() |
| 72 | } |
| 73 | |
| 74 | function getWeekNumber(date: Date): number { |
| 75 | const d = new Date(date) |
no outgoing calls
no test coverage detected