@escape-game-over/atlas 0.1.100 → 0.1.101
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/astro/client.ts +3 -0
- package/src/contact-form.ts +3 -1
- package/src/hours.ts +37 -29
- package/src/index.ts +3 -0
package/package.json
CHANGED
package/src/astro/client.ts
CHANGED
package/src/contact-form.ts
CHANGED
|
@@ -28,8 +28,10 @@ export type ContactFormType =
|
|
|
28
28
|
| "birthday_party"
|
|
29
29
|
| "board_games"
|
|
30
30
|
| "group_booking"
|
|
31
|
+
| "school_trips"
|
|
31
32
|
| "team_building"
|
|
32
|
-
| "voucher"
|
|
33
|
+
| "voucher"
|
|
34
|
+
| "vr_games";
|
|
33
35
|
|
|
34
36
|
/** Where a deployment's contact mail goes. */
|
|
35
37
|
export interface MailEndpoint {
|
package/src/hours.ts
CHANGED
|
@@ -164,6 +164,13 @@ export function groupHours(
|
|
|
164
164
|
return [...groups.values()];
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
/**
|
|
168
|
+
* Which clock times print on: `"h23"` as written (`14:00`), `"h12"` on a
|
|
169
|
+
* 12-hour clock (`2:00 PM`). Never the locale's default, which gives Greek a
|
|
170
|
+
* 12-hour clock nobody there uses on a door.
|
|
171
|
+
*/
|
|
172
|
+
export type HourCycle = "h12" | "h23";
|
|
173
|
+
|
|
167
174
|
/**
|
|
168
175
|
* How to print a week. Day names come from `Intl` in `locale`; "closed" is
|
|
169
176
|
* copy, so the caller translates it.
|
|
@@ -175,12 +182,8 @@ export interface HoursFormat {
|
|
|
175
182
|
weekday?: "short" | "long";
|
|
176
183
|
/** The word for a day the venue is shut. */
|
|
177
184
|
closed: string;
|
|
178
|
-
/**
|
|
179
|
-
|
|
180
|
-
* Not the locale's default, which gives Greek a 12-hour clock nobody there
|
|
181
|
-
* uses on a door.
|
|
182
|
-
*/
|
|
183
|
-
hourCycle?: "h12";
|
|
185
|
+
/** As written (`"h23"`) when absent. */
|
|
186
|
+
hourCycle?: HourCycle;
|
|
184
187
|
/** Between the ends of a span: `Mon–Thu`, `14:00–23:30`. */
|
|
185
188
|
between?: string;
|
|
186
189
|
/** Between spans: `Mon–Thu, Sun`. */
|
|
@@ -304,6 +307,33 @@ export function hoursSentence(
|
|
|
304
307
|
.join(semicolon);
|
|
305
308
|
}
|
|
306
309
|
|
|
310
|
+
/** How `formatTime` prints a time. */
|
|
311
|
+
export interface TimeFormat {
|
|
312
|
+
/** The language the clock is read in, e.g. `"en-US"`. */
|
|
313
|
+
readonly locale: string;
|
|
314
|
+
/** As written (`"h23"`) when absent. */
|
|
315
|
+
readonly hourCycle?: HourCycle;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* One time as the hours print it: as written (`14:00`), or on a 12-hour clock
|
|
320
|
+
* (`2:00 PM`). For a line that quotes a single time, such as "open until",
|
|
321
|
+
* so it reads like the table beside it.
|
|
322
|
+
*/
|
|
323
|
+
export function formatTime(at: TimeOfDay, format: TimeFormat): string {
|
|
324
|
+
if (format.hourCycle !== "h12") return at;
|
|
325
|
+
return new Intl.DateTimeFormat(format.locale, {
|
|
326
|
+
hour: "numeric",
|
|
327
|
+
minute: "2-digit",
|
|
328
|
+
hourCycle: "h12",
|
|
329
|
+
timeZone: "UTC",
|
|
330
|
+
}).format(
|
|
331
|
+
new Date(
|
|
332
|
+
Date.UTC(2024, 0, 1, Number(at.slice(0, 2)), Number(at.slice(3, 5)))
|
|
333
|
+
)
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
|
|
307
337
|
/** Day names and times as `format` prints them. */
|
|
308
338
|
function printer(
|
|
309
339
|
format: Pick<HoursFormat, "locale" | "weekday" | "hourCycle">
|
|
@@ -315,29 +345,7 @@ function printer(
|
|
|
315
345
|
});
|
|
316
346
|
const dayName = (day: Weekday): string =>
|
|
317
347
|
names.format(new Date(Date.UTC(2024, 0, 1 + WEEK.indexOf(day))));
|
|
318
|
-
const
|
|
319
|
-
format.hourCycle === "h12"
|
|
320
|
-
? new Intl.DateTimeFormat(format.locale, {
|
|
321
|
-
hour: "numeric",
|
|
322
|
-
minute: "2-digit",
|
|
323
|
-
hourCycle: "h12",
|
|
324
|
-
timeZone: "UTC",
|
|
325
|
-
})
|
|
326
|
-
: undefined;
|
|
327
|
-
const time = (at: TimeOfDay): string =>
|
|
328
|
-
clock === undefined
|
|
329
|
-
? at
|
|
330
|
-
: clock.format(
|
|
331
|
-
new Date(
|
|
332
|
-
Date.UTC(
|
|
333
|
-
2024,
|
|
334
|
-
0,
|
|
335
|
-
1,
|
|
336
|
-
Number(at.slice(0, 2)),
|
|
337
|
-
Number(at.slice(3, 5))
|
|
338
|
-
)
|
|
339
|
-
)
|
|
340
|
-
);
|
|
348
|
+
const time = (at: TimeOfDay): string => formatTime(at, format);
|
|
341
349
|
return { dayName, time };
|
|
342
350
|
}
|
|
343
351
|
|
package/src/index.ts
CHANGED
|
@@ -120,13 +120,16 @@ export {
|
|
|
120
120
|
type DayHours,
|
|
121
121
|
type FormattedHours,
|
|
122
122
|
formatHours,
|
|
123
|
+
formatTime,
|
|
123
124
|
groupHours,
|
|
125
|
+
type HourCycle,
|
|
124
126
|
type HoursFormat,
|
|
125
127
|
type HoursGroup,
|
|
126
128
|
type HoursSentenceFormat,
|
|
127
129
|
hoursSentence,
|
|
128
130
|
type OpenStatus,
|
|
129
131
|
openStatus,
|
|
132
|
+
type TimeFormat,
|
|
130
133
|
type TimeOfDay,
|
|
131
134
|
type TimeRange,
|
|
132
135
|
type VenueNow,
|