mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-12 21:50:43 -05:00
Removes date-fns
Removes `date-fns` dependency and replace date formatting with custom implementation.
This commit is contained in:
parent
17a614aa03
commit
73ebeca095
@ -36,8 +36,6 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"atomically": "2.0.3",
|
||||
"date-fns": "~3.6",
|
||||
"date-fns-tz": "~3.1",
|
||||
"fs-extra": "11.2.0",
|
||||
"i18n": "~0.15",
|
||||
"json5": "~2.2",
|
||||
|
@ -7,7 +7,6 @@ import type { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
import { DatabaseService } from "@spt/services/DatabaseService";
|
||||
import { RandomUtil } from "@spt/utils/RandomUtil";
|
||||
import { max } from "date-fns";
|
||||
import { inject, injectable } from "tsyringe";
|
||||
|
||||
@injectable()
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { formatInTimeZone } from "date-fns-tz";
|
||||
import { injectable } from "tsyringe";
|
||||
|
||||
/**
|
||||
@ -110,7 +109,10 @@ export class TimeUtil {
|
||||
* @returns {string} The current time as 'HH:MM' in UTC.
|
||||
*/
|
||||
public getTimeMailFormat(): string {
|
||||
return formatInTimeZone(new Date(), "UTC", "HH:mm");
|
||||
const now = new Date();
|
||||
const utcHours = now.getUTCHours().toString().padStart(2, "0");
|
||||
const utcMinutes = now.getUTCMinutes().toString().padStart(2, "0");
|
||||
return `${utcHours}:${utcMinutes}`;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -119,7 +121,11 @@ export class TimeUtil {
|
||||
* @returns {string} The current date as 'DD.MM.YYYY' in UTC.
|
||||
*/
|
||||
public getDateMailFormat(): string {
|
||||
return formatInTimeZone(new Date(), "UTC", "dd.MM.yyyy");
|
||||
const now = new Date();
|
||||
const utcDay = now.getUTCDate().toString().padStart(2, "0");
|
||||
const utcMonth = (now.getUTCMonth() + 1).toString().padStart(2, "0");
|
||||
const utcYear = now.getUTCFullYear().toString();
|
||||
return `${utcDay}.${utcMonth}.${utcYear}`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,7 +3,6 @@ import "reflect-metadata";
|
||||
import { ItemHelper } from "@spt/helpers/ItemHelper";
|
||||
import { IInsurance } from "@spt/models/eft/profile/ISptProfile";
|
||||
import { profileInsuranceFixture } from "@tests/__fixture__/profileInsurance.fixture";
|
||||
import { format } from "date-fns";
|
||||
import { container } from "tsyringe";
|
||||
|
||||
type DateInput = number | number[] | { [index: number]: number };
|
||||
@ -36,9 +35,17 @@ export class ProfileInsuranceFactory {
|
||||
date = dateInput || defaultDate;
|
||||
}
|
||||
|
||||
const dateObject = new Date(date * 1000); // Convert UNIX timestamp to milliseconds
|
||||
|
||||
const month = (dateObject.getUTCMonth() + 1).toString().padStart(2, "0");
|
||||
const day = dateObject.getUTCDate().toString().padStart(2, "0");
|
||||
const year = dateObject.getUTCFullYear();
|
||||
const hours = dateObject.getUTCHours().toString().padStart(2, "0");
|
||||
const minutes = dateObject.getUTCMinutes().toString().padStart(2, "0");
|
||||
|
||||
insurance.scheduledTime = date;
|
||||
insurance.systemData.date = format(date, "MM.dd.yyyy");
|
||||
insurance.systemData.time = format(date, "HH:mm");
|
||||
insurance.systemData.date = `${month}.${day}.${year}`;
|
||||
insurance.systemData.time = `${hours}:${minutes}`;
|
||||
return insurance;
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user