Skip to content

Commit eb6dcde

Browse files
Merge pull request #1540 from ASU/WS2-2391
Ws2 2391 - add accessibility reading to event card times
2 parents 440e37c + 27adab8 commit eb6dcde

File tree

1 file changed

+8
-5
lines changed
  • packages/component-events/src/core/utils

1 file changed

+8
-5
lines changed

packages/component-events/src/core/utils/date.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,18 @@ const formatAMPM = date => {
4444
*/
4545
export const formatTime = (startTime, endTime) => {
4646
const standardizedStartTime = standardizeTime(startTime);
47-
const standardizedEndTime = standardizeTime(endTime);
4847
let formatedStartTime = stringifyDate(new Date(standardizedStartTime));
49-
let formatedEndTime = stringifyDate(new Date(standardizedEndTime));
5048
formatedStartTime = formatAMPM(new Date(formatedStartTime));
51-
formatedEndTime = formatAMPM(new Date(formatedEndTime));
52-
if (startTime === endTime) {
49+
50+
if (!endTime || startTime === endTime) {
5351
return formatedStartTime;
5452
}
55-
return `${formatedStartTime} - ${formatedEndTime}`;
53+
54+
const standardizedEndTime = standardizeTime(endTime);
55+
let formatedEndTime = stringifyDate(new Date(standardizedEndTime));
56+
formatedEndTime = formatAMPM(new Date(formatedEndTime));
57+
58+
return `${formatedStartTime} to ${formatedEndTime}`;
5659
};
5760

5861
/**

0 commit comments

Comments
 (0)