Skip to content

Commit

Permalink
SUL23-597 Fix "today" vs "tomorrow" vs "friday" next opening day
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish committed Aug 9, 2024
1 parent 4fe076c commit c032c35
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/lib/hooks/useTodayLibraryHours.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,15 @@ const useTodayLibraryHours = (branchId?: string): HoursProps | undefined => {
}

if (nextOpenDateTime) {
const format: Intl.DateTimeFormatOptions = {hour: "numeric", minute: "numeric"}
const format: Intl.DateTimeFormatOptions = {hour: "numeric"}

if (rightNow.getDate() === nextOpenDateTime.getDate()) nextOpeningTime = "Today"
if (rightNow.getDate() + 1 === nextOpenDateTime.getDate()) nextOpeningTime = "Tomorrow"
if (rightNow.getDay() + 2 <= nextOpenDateTime.getDate())
nextOpeningTime = nextOpenDateTime.toLocaleDateString("en-us", {weekday: "long"})
if (rightNow.getDate() + 1 === nextOpenDateTime.getDate()) nextOpeningTime = "tomorrow"
if (rightNow.getDate() === nextOpenDateTime.getDate()) nextOpeningTime = "today"

if (nextOpenDateTime.getMinutes() !== 0) format.minute = "2-digit"

if (nextOpenDateTime.getMinutes() !== 0) {
format.minute = "2-digit"
}
nextOpeningTime += " " + nextOpenDateTime.toLocaleString("en-us", format).toLowerCase()
}
}
Expand Down

0 comments on commit c032c35

Please sign in to comment.