mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-21 22:29:31 +01:00
refac: message timestamp
This commit is contained in:
@@ -1,6 +1,15 @@
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import sha256 from 'js-sha256';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
import isToday from 'dayjs/plugin/isToday';
|
||||
import isYesterday from 'dayjs/plugin/isYesterday';
|
||||
|
||||
dayjs.extend(relativeTime);
|
||||
dayjs.extend(isToday);
|
||||
dayjs.extend(isYesterday);
|
||||
|
||||
import { WEBUI_BASE_URL } from '$lib/constants';
|
||||
import { TTS_RESPONSE_SPLIT } from '$lib/types';
|
||||
|
||||
@@ -281,6 +290,19 @@ export const generateInitialsImage = (name) => {
|
||||
return canvas.toDataURL();
|
||||
};
|
||||
|
||||
export const formatDate = (inputDate) => {
|
||||
const date = dayjs(inputDate);
|
||||
const now = dayjs();
|
||||
|
||||
if (date.isToday()) {
|
||||
return `Today at ${date.format('HH:mm')}`;
|
||||
} else if (date.isYesterday()) {
|
||||
return `Yesterday at ${date.format('HH:mm')}`;
|
||||
} else {
|
||||
return `${date.format('DD/MM/YYYY')} at ${date.format('HH:mm')}`;
|
||||
}
|
||||
};
|
||||
|
||||
export const copyToClipboard = async (text) => {
|
||||
let result = false;
|
||||
if (!navigator.clipboard) {
|
||||
|
||||
Reference in New Issue
Block a user