feat(standard orders in): multi customer orders in plus ignore already started
This commit is contained in:
27
server/services/logistics/utils/excelDateStuff.ts
Normal file
27
server/services/logistics/utils/excelDateStuff.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { getJsDateFromExcel } from "excel-date-to-js";
|
||||
|
||||
export const excelDateStuff = (serial: number, time: any = 0) => {
|
||||
// console.log(serial);
|
||||
// add 5 hours or the offset to utc
|
||||
|
||||
// get the local timezone
|
||||
const localoffset = new Date().getTimezoneOffset() / 60; // then divide by 60 to get the true number;
|
||||
|
||||
const addHours = serial + localoffset / 24;
|
||||
//console.log(getJsDateFromExcel(addHours));
|
||||
if (typeof serial !== "number" || serial <= 0) {
|
||||
return "invalid Date";
|
||||
}
|
||||
|
||||
const date = getJsDateFromExcel(addHours); // base date from Excel serial
|
||||
|
||||
if (time != 0) {
|
||||
// convert the time over to hour and min
|
||||
const hours = Math.floor(time / 100);
|
||||
const minutes = time % 100;
|
||||
date.setHours(hours);
|
||||
date.setMinutes(minutes);
|
||||
}
|
||||
|
||||
return date.toLocaleString("en-US"); // or .toISOString() if preferred
|
||||
};
|
||||
Reference in New Issue
Block a user