A lottery window is two calendar events, not one: Japan's 16:29 JST deadlines in vanilla JS

2026-12-02来源 dev.toEnglish

Some Japanese bookings are not first come, first served. Suntory's distillery tours are the example I keep running into: for February 2027 tours, the Hakushu lottery takes entries from 09:30 JST on 1 December to 16:29 JST on 5 December, and the Yamazaki lottery runs from 10:00 JST on 2 December to 16:29 JST on 6 December. Entering early makes no difference to the draw. The only way to lose is to miss the window.

That changes how a calendar reminder should look. I first exported each lottery as one long event, and it was useless.

Why one long event fails

A single event from 1 Dec 09:30 to 5 Dec 16:29 JST shows up as a multi-day bar. Most calendar apps fire its alarm only before the start, so you get a ping when the window opens (when there's no rush) and silence when it is about to close (when it matters).

So I model a window as two short events:

  1. Entries open: 30 minutes long, alarm 15 minutes before.
  2. Last hour to enter: ends exactly at the deadline, alarm 3 hours before its start.

The code

No library. Times are written the way the venue publishes them (local JST) and converted to UTC once.

// Japan lottery window -> two VEVENTs (opens / closing soon), no library. const JST = "+09:00"; const utc = (d) => d.toISOString().replace(/[-:]/g, "").replace(/\.\d{3}/, ""); function windowEvents({ id, name, opens, closes, url }) { const o = new Date(opens + JST), c = new Date(closes + JST); const stamp = utc(new Date()); const ev = (uid, start, mins, summary, alarm) => [ "BEGIN:VEVENT", "UID:" + uid + "@example.com", "DTSTAMP:" + stamp, "DTSTART:" + utc(start), "DURATION:PT" + mins + "M", "SUMMARY:" + summary, "URL:" + url, "BEGIN:VALARM", "ACTION:DISPLAY", "DESCRIPTION:" + summary, "TRIGGER:" + alarm, "END:VALARM", "END:VEVENT"].join("\r\n"); // The close event ENDS at the deadline, so the alarm is relative to its start. const lastCall = new Date(c.getTime() - 60 * 60000); return [ ev(id + "-open", o, 30, name + ": entries open", "-PT15M"), ev(id + "-close", lastCall, 60, name + ": last hour to enter (closes " + closes.slice(11) + " JST)", "-PT3H"), ]; } const evs = windowEvents({ id: "hakushu-2027-02", name: "Hakushu tour lottery", opens: "2026-12-01T09:30", closes: "2026-12-05T16:29", url: "https://example.com" }); console.log(evs.map(e => e.split("\r\n").filter(l => /^(DTSTART|SUMMARY|TRIGGER)/.test(l)).join(" | ")).join("\n")); 

Output:

DTSTART:20261201T003000Z | SUMMARY:Hakushu tour lottery: entries open | TRIGGER:-PT15M DTSTART:20261205T062900Z | SUMMARY:Hakushu tour lottery: last hour to enter (closes 16:29 JST) | TRIGGER:-PT3H 

Appending +09:00 to the ISO string is the whole timezone story here. Japan has no daylight saving time, so a fixed offset is correct all year. That is not true for the reader's side, which is why everything is stored in UTC (Z) and the calendar app does the local conversion.

16:29 JST is a different day for half your readers

const close = new Date("2026-12-05T16:29+09:00"); for (const tz of ["America/New_York", "America/Los_Angeles", "Europe/London", "Australia/Sydney"]) console.log(tz, new Intl.DateTimeFormat("en-GB", { timeZone: tz, weekday: "short", day: "numeric", month: "short", hour: "2-digit", minute: "2-digit" }).format(close)); 
America/New_York Sat 5 Dec, 02:29 America/Los_Angeles Fri 4 Dec, 23:29 Europe/London Sat 5 Dec, 07:29 Australia/Sydney Sat 5 Dec, 18:29 

A visitor in Los Angeles who reads "closes 5 December" and plans to enter on the evening of the 5th has already missed it by almost a day. In New York the deadline lands in the middle of the night. This is the real reason the "last hour" event's alarm is 3 hours early: a reminder at 02:29 is no reminder at all, and the extra hours move it to a waking time for more zones.

Small details that mattered

  • Odd minutes are real. 16:29, not 16:30. Do not round published times: the venue's system cuts off at the minute it states.
  • Stable UIDs. hakushu-2027-02-open and -close stay the same when you regenerate the feed, so subscribed calendars update the events instead of duplicating them.
  • DURATION instead of DTEND keeps the "ends at the deadline" logic in one place: start = deadline minus 60 minutes.
  • Results and payment are windows too. Yamazaki winners reserve and pay from 11 to 15 December. The same two-event pattern works for "pay before your win is cancelled".

Try it

I keep these windows (both distillery lotteries, with the open and close events and the per-zone times) on a free page with a subscribable .ics feed: https://hodoyoku.pages.dev/drops/yamazaki-distillery-lottery

If you build anything that turns "entries close at X local time" into reminders, the two-event pattern is the cheapest fix I've found.

原文:https://www.a8q9.cn/en/article/a-lottery-window-is-two-calendar-events-not-one-japan-s-16-29-jst-deadlines-in-v-ab007c.html

相关文章