Skip to content

Commit

Permalink
Fix date format for events (#655)
Browse files Browse the repository at this point in the history
Co-authored-by: JR Reed <mikereed101@gmail.com>
Co-authored-by: Tim Cosgrove <timcosgrove@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 26, 2024
1 parent 41012bd commit 0b1925d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib/utils/date.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ describe('deriveFormattedTimestamp', () => {
const result = deriveFormattedTimestamp(datetime)

expect(result).toMatch(
/Thu, Sep 7, 2023, \d{1,2}:\d{2} [APM]{2} [A-Z]{2,4} – \d{1,2}:\d{2} [APM]{2} [A-Z]{2,4}/
/Thu. Sep 7, 2023, \d{1,2}:\d{2} [apm]{2} [A-Z]{2,4} – \d{1,2}:\d{2} [apm]{2} [A-Z]{2,4}/
)
})
})
Expand Down
10 changes: 9 additions & 1 deletion src/lib/utils/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,15 @@ export const deriveFormattedTimestamp = (datetime) => {
})

// Format: Mon. Dec 11, 2023, 10:30 am – 11:30 am ET
return `${formattedStartTime}${formattedEndTime}`
// return `${formattedStartTime} – ${formattedEndTime}`

const formattedTime = `${formattedStartTime}${formattedEndTime}`

function reformatTime(str) {
return str.replaceAll('AM', 'am').replaceAll('PM', 'pm').replace(',', '.')
}

return reformatTime(formattedTime)
}

export const isEventInPast = (eventTime) => {
Expand Down

0 comments on commit 0b1925d

Please sign in to comment.