Two ticket releases a month: from visit date to sale time in vanilla JS, with a flag for the closure clash
The Fujiko F. Fujio Museum in Kawasaki (the "Doraemon Museum") sells timed tickets online only. It publishes a rule, not a list of dates: tickets for the 16th to the end of a month go on sale at 10:00 JST on the 5th of t
The Fujiko F. Fujio Museum in Kawasaki (the "Doraemon Museum") sells timed tickets online only. It publishes a rule, not a list of dates: tickets for the 16th to the end of a month go on sale at 10:00 JST on the 5th of that month, and tickets for the 1st to 15th of the next month at 10:00 JST on the 20th.
Visitors ask "I am there on 2 January, when can I buy?" Here is the rule as code, plus one case it cannot answer.
1. Visit date -> release instant
A visit date is a Japan calendar date, so it stays a YYYY-MM-DD string and never passes through the machine's zone. A release is an instant, so it becomes a Date with an explicit +09:00. Japan has no DST, so a fixed offset is correct all year.
const pad = (n) => String(n).padStart(2, "0");
const jst = (y, m, d) => new Date(`${y}-${pad(m)}-${pad(d)}T10:00+09:00`); // m: 1-12
function releaseFor(visit) { // "YYYY-MM-DD", a Japan date
const [y, m, d] = visit.split("-").map(Number);
if (d >= 16) return jst(y, m, 5); // 16th..end: the 5th
return m === 1 ? jst(y - 1, 12, 20) : jst(y, m - 1, 20); // 1st..15th: 20th before
}
for (const v of ["2026-12-24", "2027-01-02", "2027-01-15", "2027-01-16"])
console.log(v, releaseFor(v).toISOString());
2026-12-24 2026-12-05T01:00:00.000Z
2027-01-02 2026-12-20T01:00:00.000Z
2027-01-15 2026-12-20T01:00:00.000Z
2027-01-16 2027-01-05T01:00:00.000Z
Test the two edges on purpose: the year boundary (a 2 January visit is sold on 20 December of the year before) and the 15th/16th split, where an off-by-one sends someone to a batch two weeks later.
2. Generate the calendar
For a page or an .ics feed, list every release with the visits it covers.
function releases(y, m, count) {
const out = [];
while (out.length < count) {
out.push({ at: jst(y, m, 5), visits: `${y}-${pad(m)} 16th-end` });
const [ny, nm] = m === 12 ? [y + 1, 1] : [y, m + 1];
out.push({ at: jst(y, m, 20), visits: `${ny}-${pad(nm)} 1st-15th` });
[y, m] = [ny, nm];
}
return out.slice(0, count);
}
Every release comes out as T01:00:00.000Z. Without the +09:00, "10:00" would be read in the build machine's zone, and a feed built on a UTC server would be nine hours late.
3. 10:00 JST on the reader's clock
Store UTC, convert only for display. Intl.DateTimeFormat with timeZone does it, the reader's DST included.
const fmt = (tz) => new Intl.DateTimeFormat("en-GB", { timeZone: tz,
weekday: "short", day: "numeric", month: "short", hour: "2-digit", minute: "2-digit" });
const at = releaseFor("2027-01-02");
for (const tz of ["Europe/London", "America/New_York", "America/Los_Angeles"])
console.log(tz.padEnd(20), fmt(tz).format(at));
const me = Intl.DateTimeFormat().resolvedOptions().timeZone;
console.log("you:", fmt(me).format(at), `(${me})`);
Europe/London Sun 20 Dec, 01:00
America/New_York Sat 19 Dec, 20:00
America/Los_Angeles Sat 19 Dec, 17:00
you: Sun 20 Dec, 10:00 (Asia/Tokyo)
With TZ=America/New_York node the last line becomes you: Sat 19 Dec, 20:00 (America/New_York). The New Year batch goes on sale on a Saturday evening in the Americas, a day before the date the museum states. Always print the weekday.
4. A release day inside a closure: flag it, don't guess
The official calendar shows the museum closed from 18 to 22 January 2027. The rule puts the 1-15 February release on 20 January. Does the online sale open on a day the building is closed? The official pages do not say.
Moving it to the next open day, or dropping it, would both be guesses, and a wrong guess costs a reader the tickets. So the code keeps the rule's date and marks it.
const closures = [["2026-12-29", "2027-01-03"], ["2027-01-18", "2027-01-22"]];
const jstDate = (d) => new Date(d.getTime() + 9 * 3600e3).toISOString().slice(0, 10);
for (const r of releases(2026, 12, 5)) {
const day = jstDate(r.at);
const c = closures.find(([a, b]) => day >= a && day <= b);
r.status = c ? `UNCONFIRMED: inside ${c[0]}..${c[1]} closure` : "rule";
console.log(day, r.visits, "|", r.status);
}
2026-12-05 2026-12 16th-end | rule
2026-12-20 2027-01 1st-15th | rule
2027-01-05 2027-01 16th-end | rule
2027-01-20 2027-02 1st-15th | UNCONFIRMED: inside 2027-01-18..2027-01-22 closure
2027-02-05 2027-02 16th-end | rule
jstDate adds nine hours and reads the UTC date, which gives the Japan date on any machine (with TZ=UTC and TZ=Pacific/Kiritimati the output is the same, apart from the you: line). YYYY-MM-DD strings sort correctly, so >= and <= work as a range check.
The status drives the output: a caveat on that row ("check the sales page at 10:00 JST that day"), a note in the .ics event, and a re-check around 18-20 January. When the museum confirms, the flag goes away in the data, not in code.
Takeaways
- Model the published rule; the date list is a testable output.
- Calendar dates are strings, instants are
Dates with explicit offsets. - Show the weekday in the reader's zone.
- When two official facts collide, store the conflict as data. "Unconfirmed" is a valid state.
The release days to February 2027, with the closed days in each batch and a calendar reminder per release, are on this free page: https://hodoyoku.pages.dev/drops/fujiko-f-fujio-museum
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.