Skip to content

Commit

Permalink
Improved: time on the query page to be displayed in 12-hour format(#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
ymaheshwari1 committed Apr 18, 2024
1 parent 95f3bdb commit 2e2781c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const sortSequence = (sequence: Array<Group | Route | Rule>, sortOnField = "sequ
}

const getTime = (time: any) => {
// Directly using TIME_SIMPLE for formatting the time does not work, as the Intl is set in that way. So, using hourCycle to always get the time in 12-hour format
// Directly using TIME_SIMPLE for formatting the time results the time always in 24-hour format, as the Intl is set in that way. So, using hourCycle to always get the time in 12-hour format
// https://github.com/moment/luxon/issues/998
return time ? DateTime.fromMillis(time).toLocaleString({ ...DateTime.TIME_SIMPLE, hourCycle: "h12" }) : "-";
}
Expand All @@ -48,8 +48,9 @@ function getDateAndTime(time: any) {
}

function getDateAndTimeShort(time: any) {
// format: hh:mm(localized 24-hour time) date/month
return time ? DateTime.fromMillis(time).toFormat("T dd/LL") : "-";
// format: hh:mm(localized 12-hour time) date/month
// Using toLocaleString as toFormat is not converting the time in 12-hour format
return time ? DateTime.fromMillis(time).toLocaleString({ hour: "numeric", minute: "numeric", day: "numeric", month: "numeric", hourCycle: "h12" }) : "-";
}

function timeTillRun(endTime: any) {
Expand Down

0 comments on commit 2e2781c

Please sign in to comment.