feat(dm): migrated all the dm topics
All checks were successful
Build and Push LST Docker Image / docker (push) Successful in 4m26s

This commit is contained in:
2026-06-26 11:05:17 -05:00
parent 012a7e83b2
commit 47b149d1ea
48 changed files with 14156 additions and 44 deletions

View File

@@ -1,21 +1,23 @@
import { getJsDateFromExcel } from "excel-date-to-js";
export const excelDateStuff = (serial: number, time?: any) => {
export const excelDateStuff = (
serial: number,
defaultTime = 800,
time?: number,
) => {
if (typeof serial !== "number" || serial <= 0) {
return "invalid Date";
}
// Default time to 8:00 AM if not provided
if (!time) {
time = 800;
}
// Get base date from Excel serial (this gives you UTC midnight)
const date = getJsDateFromExcel(serial);
const excelTime = excelSerialToTime(serial);
const finalTime = time ?? excelTime ?? defaultTime;
const date = getJsDateFromExcel(Math.floor(serial));
const localOffset = new Date().getTimezoneOffset() / 60;
const hours = Math.floor(time / 100);
const minutes = time % 100;
const hours = Math.floor(finalTime / 100);
const minutes = finalTime % 100;
// Set the time in UTC
date.setUTCHours(hours + localOffset);
@@ -26,3 +28,17 @@ export const excelDateStuff = (serial: number, time?: any) => {
//console.log(date.toISOString(), serial, time);
return date.toISOString();
};
const excelSerialToTime = (serial: number): number | null => {
const fraction = serial % 1;
if (fraction <= 0) {
return null;
}
const totalMinutes = Math.round(fraction * 24 * 60);
const hours = Math.floor(totalMinutes / 60);
const minutes = totalMinutes % 60;
return hours * 100 + minutes;
};