fix today being berlin timezone

This commit is contained in:
Darius
2026-02-07 00:37:45 +01:00
parent bef511ea72
commit d5b178fabe
3 changed files with 28 additions and 3 deletions

18
package-lock.json generated
View File

@@ -17,10 +17,12 @@
"fastify": "^5.6.2", "fastify": "^5.6.2",
"fastify-axios": "^1.3.0", "fastify-axios": "^1.3.0",
"fastify-type-provider-zod": "^6.1.0", "fastify-type-provider-zod": "^6.1.0",
"luxon": "^3.7.2",
"swagger-themes": "^1.4.3", "swagger-themes": "^1.4.3",
"zod": "^4.1.12" "zod": "^4.1.12"
}, },
"devDependencies": { "devDependencies": {
"@types/luxon": "^3.7.1",
"@types/node": "^24.10.1", "@types/node": "^24.10.1",
"@types/ws": "^8.18.1", "@types/ws": "^8.18.1",
"tsx": "^4.20.6", "tsx": "^4.20.6",
@@ -780,6 +782,13 @@
"integrity": "sha512-k2ENnmBugE/rzQfEcdWHcCY+/FM3VLzH9cYEsbdsoqrvzAKRhUZeRNhAZvB8OitQJ1TBed3yqWtdjzS6wJKBwg==", "integrity": "sha512-k2ENnmBugE/rzQfEcdWHcCY+/FM3VLzH9cYEsbdsoqrvzAKRhUZeRNhAZvB8OitQJ1TBed3yqWtdjzS6wJKBwg==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/@types/luxon": {
"version": "3.7.1",
"resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-3.7.1.tgz",
"integrity": "sha512-H3iskjFIAn5SlJU7OuxUmTEpebK6TKB8rxZShDslBMZJ5u9S//KM1sbdAisiSrqwLQncVjnpi2OK2J51h+4lsg==",
"dev": true,
"license": "MIT"
},
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "24.10.11", "version": "24.10.11",
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.11.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.11.tgz",
@@ -1586,6 +1595,15 @@
"node": "20 || >=22" "node": "20 || >=22"
} }
}, },
"node_modules/luxon": {
"version": "3.7.2",
"resolved": "https://registry.npmjs.org/luxon/-/luxon-3.7.2.tgz",
"integrity": "sha512-vtEhXh/gNjI9Yg1u4jX/0YVPMvxzHuGgCm6tC5kZyb08yjGWGnqAjGJvcXbqQR2P3MyMEFnRbpcdFS6PBcLqew==",
"license": "MIT",
"engines": {
"node": ">=12"
}
},
"node_modules/math-intrinsics": { "node_modules/math-intrinsics": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",

View File

@@ -22,10 +22,12 @@
"fastify": "^5.6.2", "fastify": "^5.6.2",
"fastify-axios": "^1.3.0", "fastify-axios": "^1.3.0",
"fastify-type-provider-zod": "^6.1.0", "fastify-type-provider-zod": "^6.1.0",
"luxon": "^3.7.2",
"swagger-themes": "^1.4.3", "swagger-themes": "^1.4.3",
"zod": "^4.1.12" "zod": "^4.1.12"
}, },
"devDependencies": { "devDependencies": {
"@types/luxon": "^3.7.1",
"@types/node": "^24.10.1", "@types/node": "^24.10.1",
"@types/ws": "^8.18.1", "@types/ws": "^8.18.1",
"tsx": "^4.20.6", "tsx": "^4.20.6",

View File

@@ -4,6 +4,7 @@ import {
logWarning, logWarning,
type ServiceResult, type ServiceResult,
} from "@dpu/shared"; } from "@dpu/shared";
import { DateTime } from "luxon";
import { Config } from "../config.js"; import { Config } from "../config.js";
import type { GristClient } from "./client.js"; import type { GristClient } from "./client.js";
@@ -35,9 +36,13 @@ export class GristService extends BaseService<GristClient> {
} }
} }
private getTodayAsId(date = new Date()) { private getTodayAsId() {
const start = new Date(date.getFullYear(), 0, 0); const now = DateTime.now().setZone("Europe/Berlin");
const diff = date.getTime() - start.getTime(); const start = DateTime.fromObject(
{ year: now.year, month: 0, day: 0, hour: 0, minute: 0 },
{ zone: "Europe/Berlin" },
);
const diff = start.diff(now).toMillis();
return Math.floor(diff / 86400000); return Math.floor(diff / 86400000);
} }