test(rfid): more rfid work and tested working

This commit is contained in:
2025-04-17 18:42:29 -05:00
parent af8d53cac1
commit a68a3ba640
5 changed files with 62 additions and 16 deletions

View File

@@ -1,6 +1,17 @@
import { format } from "date-fns";
import { addHours, format } from "date-fns";
export const fixTime = (date: any) => {
const strippedDate = date.replace("Z", ""); // Remove Z
return format(strippedDate, "MM/dd/yyyy hh:mm a");
if (!date) return;
// const strippedDate = date?.replace("Z", ""); // Remove Z
//return format(strippedDate, "MM/dd/yyyy hh:mm a");
const rawDate = new Date(date).toISOString();
const offsetMinutes = new Date().getTimezoneOffset(); // in minutes
const offsetHours =
-offsetMinutes / 60 >= 0 ? offsetMinutes / 60 : -offsetMinutes / 60;
return format(
addHours(rawDate, offsetHours).toISOString(),
"MM/dd/yyyy hh:mm a"
);
};