diff --git a/src/app/atoms/time/Time.jsx b/src/app/atoms/time/Time.jsx index d2159f7b..96e7704b 100644 --- a/src/app/atoms/time/Time.jsx +++ b/src/app/atoms/time/Time.jsx @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'; import dateFormat from 'dateformat'; import { isInSameDay } from '../../../util/common'; -function Time({ timestamp, fullTime, hour24Clock }) { +function Time({ timestamp, fullTime, hour24Clock, dateFormatString }) { const date = new Date(timestamp); const formattedFullTime = dateFormat( @@ -21,7 +21,7 @@ function Time({ timestamp, fullTime, hour24Clock }) { const timeFormat = hour24Clock ? 'HH:MM' : 'hh:MM TT'; - formattedDate = dateFormat(date, isToday || isYesterday ? timeFormat : 'dd/mm/yyyy'); + formattedDate = dateFormat(date, isToday || isYesterday ? timeFormat : dateFormatString); if (isYesterday) { formattedDate = `Yesterday, ${formattedDate}`; } @@ -42,6 +42,7 @@ Time.propTypes = { timestamp: PropTypes.number.isRequired, fullTime: PropTypes.bool, hour24Clock: PropTypes.bool.isRequired, + dateFormatString: PropTypes.string.isRequired, }; export default Time; diff --git a/src/app/components/message/Time.tsx b/src/app/components/message/Time.tsx index c2cd3943..f06662fb 100644 --- a/src/app/components/message/Time.tsx +++ b/src/app/components/message/Time.tsx @@ -6,10 +6,11 @@ export type TimeProps = { compact?: boolean; ts: number; hour24Clock: boolean; + dateFormatString: string; }; export const Time = as<'span', TimeProps & ComponentProps>( - ({ compact, hour24Clock, ts, ...props }, ref) => { + ({ compact, hour24Clock, dateFormatString, ts, ...props }, ref) => { const formattedTime = timeHourMinute(ts, hour24Clock); let time = ''; @@ -20,7 +21,7 @@ export const Time = as<'span', TimeProps & ComponentProps>( } else if (yesterday(ts)) { time = `Yesterday ${formattedTime}`; } else { - time = `${timeDayMonYear(ts)} ${formattedTime}`; + time = `${timeDayMonYear(ts, dateFormatString)} ${formattedTime}`; } return ( diff --git a/src/app/features/message-search/MessageSearch.tsx b/src/app/features/message-search/MessageSearch.tsx index 227c7e78..26085b5f 100644 --- a/src/app/features/message-search/MessageSearch.tsx +++ b/src/app/features/message-search/MessageSearch.tsx @@ -58,6 +58,7 @@ export function MessageSearch({ const [legacyUsernameColor] = useSetting(settingsAtom, 'legacyUsernameColor'); const [hour24Clock] = useSetting(settingsAtom, 'hour24Clock'); + const [dateFormatString] = useSetting(settingsAtom, 'dateFormatString'); const searchInputRef = useRef(null); const scrollTopAnchorRef = useRef(null); @@ -292,6 +293,7 @@ export function MessageSearch({ onOpen={navigateRoom} legacyUsernameColor={legacyUsernameColor || mDirects.has(groupRoom.roomId)} hour24Clock={hour24Clock} + dateFormatString={dateFormatString} /> ); diff --git a/src/app/features/message-search/SearchResultGroup.tsx b/src/app/features/message-search/SearchResultGroup.tsx index c0301699..bc94092b 100644 --- a/src/app/features/message-search/SearchResultGroup.tsx +++ b/src/app/features/message-search/SearchResultGroup.tsx @@ -58,6 +58,7 @@ type SearchResultGroupProps = { onOpen: (roomId: string, eventId: string) => void; legacyUsernameColor?: boolean; hour24Clock: boolean; + dateFormatString: string; }; export function SearchResultGroup({ room, @@ -68,6 +69,7 @@ export function SearchResultGroup({ onOpen, legacyUsernameColor, hour24Clock, + dateFormatString, }: SearchResultGroupProps) { const mx = useMatrixClient(); const useAuthentication = useMediaAuthentication(); @@ -277,7 +279,11 @@ export function SearchResultGroup({ {tagIconSrc && } -