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

View File

@@ -4,6 +4,7 @@ import {
logWarning,
type ServiceResult,
} from "@dpu/shared";
import { DateTime } from "luxon";
import { Config } from "../config.js";
import type { GristClient } from "./client.js";
@@ -35,9 +36,13 @@ export class GristService extends BaseService<GristClient> {
}
}
private getTodayAsId(date = new Date()) {
const start = new Date(date.getFullYear(), 0, 0);
const diff = date.getTime() - start.getTime();
private getTodayAsId() {
const now = DateTime.now().setZone("Europe/Berlin");
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);
}