diff --git a/src/app/atoms/time/Time.jsx b/src/app/atoms/time/Time.jsx index 750b958f..d2159f7b 100644 --- a/src/app/atoms/time/Time.jsx +++ b/src/app/atoms/time/Time.jsx @@ -4,10 +4,13 @@ import PropTypes from 'prop-types'; import dateFormat from 'dateformat'; import { isInSameDay } from '../../../util/common'; -function Time({ timestamp, fullTime }) { +function Time({ timestamp, fullTime, hour24Clock }) { const date = new Date(timestamp); - const formattedFullTime = dateFormat(date, 'dd mmmm yyyy, hh:MM TT'); + const formattedFullTime = dateFormat( + date, + hour24Clock ? 'dd mmmm yyyy, HH:MM' : 'dd mmmm yyyy, hh:MM TT' + ); let formattedDate = formattedFullTime; if (!fullTime) { @@ -16,17 +19,16 @@ function Time({ timestamp, fullTime }) { compareDate.setDate(compareDate.getDate() - 1); const isYesterday = isInSameDay(date, compareDate); - formattedDate = dateFormat(date, isToday || isYesterday ? 'hh:MM TT' : 'dd/mm/yyyy'); + const timeFormat = hour24Clock ? 'HH:MM' : 'hh:MM TT'; + + formattedDate = dateFormat(date, isToday || isYesterday ? timeFormat : 'dd/mm/yyyy'); if (isYesterday) { formattedDate = `Yesterday, ${formattedDate}`; } } return ( -