This commit is contained in:
wchino
2026-06-13 17:38:25 +08:00
parent e7e938f261
commit 7b33d9f9fa
190 changed files with 23222 additions and 4336 deletions

View File

@@ -0,0 +1,41 @@
import {
formatLocalMatchDateTime,
isAfterLocalToday,
isInLocalToday,
isoToPlatformPickerDateTime,
platformPickerDateTimeToIso,
} from '@thebet365/shared';
describe('match time helpers', () => {
it('converts Malaysia picker time to UTC ISO and back', () => {
const iso = platformPickerDateTimeToIso('2026-06-11T19:00:00');
expect(iso).toBe('2026-06-11T11:00:00.000Z');
expect(isoToPlatformPickerDateTime(iso)).toBe('2026-06-11T19:00:00');
});
it('formats the same kickoff in different local time zones with GMT offsets', () => {
const malaysia = formatLocalMatchDateTime('2026-06-11T11:00:00.000Z', 'en-US', {
variant: 'full',
timeZone: 'Asia/Kuala_Lumpur',
});
const newYork = formatLocalMatchDateTime('2026-06-11T11:00:00.000Z', 'en-US', {
variant: 'full',
timeZone: 'America/New_York',
});
expect(malaysia).toContain('07:00');
expect(malaysia).toContain('GMT+8');
expect(newYork).toContain('07:00');
expect(newYork).toContain('GMT-4');
expect(malaysia).not.toBe(newYork);
});
it('uses the player local day for today and early buckets', () => {
const now = new Date('2026-06-11T15:00:00-04:00');
expect(isInLocalToday('2026-06-12T02:00:00.000Z', now, 'America/New_York')).toBe(true);
expect(isAfterLocalToday('2026-06-12T05:00:00.000Z', now, 'America/New_York')).toBe(true);
});
});