|
|
@@ -68,12 +68,21 @@ const convertDateTime = (dateTimeString) => {
|
|
|
* // Output: 23/05/2023 10:07:27
|
|
|
*/
|
|
|
const formatDateYMDtoDMY = (dateTime) => {
|
|
|
- const [datePart, timePart] = dateTime.split(" ");
|
|
|
+ if (!dateTime || typeof dateTime !== "string") return "-";
|
|
|
+
|
|
|
+ const normalizedDateTime = dateTime.trim().replace("T", " ");
|
|
|
+ if (!normalizedDateTime) return "-";
|
|
|
+
|
|
|
+ const [datePart, timePart] = normalizedDateTime.split(" ");
|
|
|
const [year, month, day] = datePart.split("-");
|
|
|
+ if (!year || !month || !day) return "-";
|
|
|
+
|
|
|
const formattedDate = `${day}/${month}/${year}`;
|
|
|
if (timePart) {
|
|
|
- const [hours, minutes, seconds] = timePart.split(":");
|
|
|
- const formattedTime = `${hours}:${minutes}:${seconds}`;
|
|
|
+ const [hours, minutes, seconds = "00"] = timePart
|
|
|
+ .replace("Z", "")
|
|
|
+ .split(":");
|
|
|
+ const formattedTime = `${hours}:${minutes}:${seconds.split(".")[0]}`;
|
|
|
return `${formattedDate} ${formattedTime}`;
|
|
|
}
|
|
|
return formattedDate;
|