Skip to content

Commit

Permalink
sonar cloud issue fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ajay-aot committed Oct 28, 2024
1 parent 28218b4 commit 5d927d2
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from "react";
import { useState, useRef, useEffect } from "react";
import React, { useState, useRef, useEffect } from "react";
import Modal from "react-bootstrap/Modal";
import { CustomButton } from "./Button";
import { CloseIcon } from "../SvgIcons/index";
Expand Down Expand Up @@ -45,13 +44,12 @@ const formatDate = (dateString: string) => {
const day = String(date.getDate()).padStart(2, "0");
const month = String(date.getMonth() + 1).padStart(2, "0"); // Months are 0-based
const year = String(date.getFullYear()).slice(-2); // Last two digits of year
let hours = date.getHours();
const rawHours = date.getHours();
const minutes = String(date.getMinutes()).padStart(2, "0");
const ampm = hours >= 12 ? "PM" : "AM";
const ampm = rawHours >= 12 ? "PM" : "AM";
// Convert 24-hour format to 12-hour format
hours = hours % 12;
hours = hours ? hours : 12; // hour '0' should be '12'
const formattedHours = String(hours).padStart(2, "0");
const displayHours = rawHours % 12 || 12; // '0' hour should be '12'
const formattedHours = String(displayHours).padStart(2, "0");

return `${day}-${month}-${year} ${formattedHours}:${minutes}${ampm}`;
};
Expand Down

0 comments on commit 5d927d2

Please sign in to comment.