mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-09 05:39:12 +00:00
Fix date time rendering when print conversation on web app
This commit is contained in:
@@ -946,7 +946,7 @@ export default function AllConversations(props: SidePanelProps) {
|
|||||||
|
|
||||||
const currentDate = new Date();
|
const currentDate = new Date();
|
||||||
|
|
||||||
chatSessions.forEach((chatSessionMetadata) => {
|
chatSessions?.forEach((chatSessionMetadata) => {
|
||||||
const chatDate = new Date(chatSessionMetadata.updated);
|
const chatDate = new Date(chatSessionMetadata.updated);
|
||||||
const diffTime = Math.abs(currentDate.getTime() - chatDate.getTime());
|
const diffTime = Math.abs(currentDate.getTime() - chatDate.getTime());
|
||||||
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
|
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
|
||||||
|
|||||||
@@ -721,7 +721,22 @@ const ChatMessage = forwardRef<HTMLDivElement, ChatMessageProps>((props, ref) =>
|
|||||||
|
|
||||||
function formatDate(timestamp: string) {
|
function formatDate(timestamp: string) {
|
||||||
// Format date in HH:MM, DD MMM YYYY format
|
// Format date in HH:MM, DD MMM YYYY format
|
||||||
let date = new Date(timestamp + "Z");
|
// Handle timestamps in "YYYY-MM-DD HH:MM:SS" format from backend
|
||||||
|
let date: Date;
|
||||||
|
if (timestamp.includes(" ") && !timestamp.includes("T")) {
|
||||||
|
// Convert "YYYY-MM-DD HH:MM:SS" to ISO format
|
||||||
|
date = new Date(timestamp.replace(" ", "T") + "Z");
|
||||||
|
} else if (!timestamp.endsWith("Z")) {
|
||||||
|
date = new Date(timestamp + "Z");
|
||||||
|
} else {
|
||||||
|
date = new Date(timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if date is valid
|
||||||
|
if (isNaN(date.getTime())) {
|
||||||
|
return "Invalid Date";
|
||||||
|
}
|
||||||
|
|
||||||
let time_string = date
|
let time_string = date
|
||||||
.toLocaleTimeString("en-US", { hour: "2-digit", minute: "2-digit", hour12: true })
|
.toLocaleTimeString("en-US", { hour: "2-digit", minute: "2-digit", hour12: true })
|
||||||
.toUpperCase();
|
.toUpperCase();
|
||||||
|
|||||||
Reference in New Issue
Block a user