Fix message timestamp showing incorrect relative dates.

This commit is contained in:
ADAMJR 2023-01-05 15:01:57 +00:00
parent 4633062bf4
commit d47476d5b9
3 changed files with 3 additions and 2 deletions

View File

@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
### Fixed
- Message formatting does not work.
- Message dates no longer show 2 days ago as 'Yesterday'.
### Changed
### Removed

View File

@ -16,7 +16,7 @@ const MessageTimestamp: FunctionComponent<MessageTimestampProps> = ({ message })
function getTimestamp() {
const wasToday = midnight.getDate() === createdAt.getDate();
if (wasToday) return '[Today at] HH:mm';
else if (daysAgo === 1) return '[Yesterday at] HH:mm';
else if (daysAgo <= 1) return '[Yesterday at] HH:mm';
return 'DD/MM/YYYY';
}
return <span>{moment(createdAt).format(getTimestamp())}</span>;

View File

@ -14,7 +14,7 @@ export class FormatService {
codeLine: /`(.*?)`/gs,
blockQuoteMultiline: />>> (.*)/gs,
blockQuoteLine: /^> (.*)$/gm,
url: /(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*))/gm,
url: /(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+~#?&//=]*))/gm,
};
public toHTML(content: string) {