Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 54x 54x 54x 54x 1x 1x 1x 1x 1x 1x 1x 1x 1x 58x 58x 9x 58x 8x 58x 58x 58x 3x 3x 5x 5x 5x 5x 58x 58x 58x 58x | /**
* The match page's hero (SB-1906): when a match kicks off, said the way the
* tournament schedule says it.
*
* A tournament's schedule lists kickoffs in venue time (SB-1883), so the
* match page leads with venue time too, and adds the viewer's own clock only
* when it reads differently. Before this the list said 3:15 PM and the page
* said 5:15 PM for the same match.
*/
import {
formatKickoff,
venueTimeZone,
zoneAbbreviation,
} from './tournamentDays';
const viewerZone = () => {
try {
return Intl.DateTimeFormat().resolvedOptions().timeZone || null;
} catch {
return null;
}
};
/**
* `{ clock, zone, yourTime }` for a match's kickoff, or null without one.
*
* `clock` is venue time for a tournament match whose venue has a known zone,
* the viewer's time otherwise. `zone` ("MST") is set only when the clock is
* venue time and that is not the viewer's zone. `yourTime` is the viewer's
* clock when it reads differently from `clock`, else null.
*/
export function heroKickoff(match, localZone = viewerZone()) {
const iso = match?.scheduled_kickoff;
if (!iso) return null;
const at = new Date(iso);
if (Number.isNaN(at.getTime())) return null;
const venue = match?.tournament_id
? venueTimeZone({ location: match.tournament_location })
: null;
if (!venue || venue === localZone) {
return { clock: formatKickoff(iso, localZone), zone: null, yourTime: null };
}
const clock = formatKickoff(iso, venue);
const mine = formatKickoff(iso, localZone);
return {
clock,
zone: zoneAbbreviation(venue, at) || null,
yourTime: mine && mine !== clock ? mine : null,
};
}
|