mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-19 05:26:47 +00:00
a8fc93dfde
The reminder crons run at 09:00 in the instance's TZ but computed today in UTC, so east of Greenwich a trip reminder arrived a day late. A day the job did not run also lost that day's trip reminders for good: the match was 'starts exactly N days from today'. Trips now record the start date a reminder went out for, and the job sends every reminder that is due and not yet sent. The active-trip redirect and the upcoming reservations use the instance's date and clock as well.
23 lines
916 B
TypeScript
23 lines
916 B
TypeScript
import { afterEach, describe, expect, it } from 'vitest';
|
|
import { appClock } from '../../../src/nest/common/timezoneService';
|
|
|
|
describe('appClock', () => {
|
|
const realTz = process.env.TZ;
|
|
afterEach(() => {
|
|
process.env.TZ = realTz;
|
|
});
|
|
|
|
it('APPCLOCK-001: reads the date and time where the instance runs, not in UTC', () => {
|
|
process.env.TZ = 'Australia/Sydney';
|
|
// 23:30 UTC on the 6th is 10:30 on the 7th in Sydney.
|
|
expect(appClock(new Date('2026-10-06T23:30:00Z'))).toEqual({ date: '2026-10-07', time: '10:30' });
|
|
});
|
|
|
|
it('APPCLOCK-002: falls back to UTC without a TZ, and for one Intl does not know', () => {
|
|
delete process.env.TZ;
|
|
expect(appClock(new Date('2026-10-06T23:30:00Z'))).toEqual({ date: '2026-10-06', time: '23:30' });
|
|
process.env.TZ = 'Not/AZone';
|
|
expect(appClock(new Date('2026-10-06T23:30:00Z'))).toEqual({ date: '2026-10-06', time: '23:30' });
|
|
});
|
|
});
|