Keep school dates in the school's timezone
The container runs on UTC and the school does not: at 00:30 in Erfurt the process clock still says yesterday, so anything deriving "today" from a Date would prepare the wrong school day twice a night. core/dates.ts holds calendar dates as plain YYYY-MM-DD strings, which is what a school day is — today in Europe/Berlin, whole-day arithmetic anchored at noon UTC so no daylight-saving change can shift a date, the German weekday and day formats, and the compact form the timetable API takes. isCalendarDate round-trips rather than only matching a shape: Date.parse turns 2026-02-30 into March 2nd instead of refusing it, so a shape check alone would let a caller read a different day than it asked for. germanDate moves here from mcp/prompts.ts, its only previous home, so the timezone is stated in one place. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { describe, it } from 'node:test';
|
||||
import { ErrorCode } from '@modelcontextprotocol/sdk/types.js';
|
||||
import { argumentText, examPrompt, germanDate, resolveTarget, summaryPrompt, type Target } from '../src/mcp/prompts.ts';
|
||||
import { germanDate } from '../src/core/dates.ts';
|
||||
import { argumentText, examPrompt, resolveTarget, summaryPrompt, type Target } from '../src/mcp/prompts.ts';
|
||||
import { ProtocolError } from '../src/mcp/tools/result.ts';
|
||||
|
||||
const CANDIDATES: Target[] = [
|
||||
@@ -151,3 +152,4 @@ describe('germanDate', () => {
|
||||
assert.equal(germanDate(new Date('2026-09-14T23:30:00Z')), 'Dienstag, 15.09.2026');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user