@sarimarcus/content-sites-core 0.38.0 → 0.39.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  All packages in the platform release in lockstep; entries are per release version.
4
4
 
5
+ ## 0.39.0 (2026-10-16)
6
+
7
+ - `schema`: `hours.ts` exports `CLOCK_TIME`, the clock-time pattern `parseHoursShifts` and `latestClosing` now share; no behaviour change (SLA-3045).
8
+
9
+ ## 0.38.1 (2026-10-15)
10
+
11
+ - No changes; lockstep release with tourism (SLA-3125).
12
+
5
13
  ## 0.38.0 (2026-10-15)
6
14
 
7
15
  - `articles`: new `selectRecentlyUpdated(articles, {datesOf, now, exclude?, windowDays?, max?})` (60-day window, max 3, newest update first), `isUpdatedAfterPublication` and the `RECENT_UPDATE_*` defaults, for the articles hub "Recently updated" shelf; the window is counted in calendar days, so a build-day rewrite stays in (SLA-3120).
@@ -3,6 +3,8 @@ export declare const DAY_KEYS: readonly ["monday", "tuesday", "wednesday", "thur
3
3
  export type DayKey = (typeof DAY_KEYS)[number];
4
4
  /** The value an `openingHours` bucket uses for a day open around the clock. */
5
5
  export declare const HOURS_ALWAYS_OPEN = "24h";
6
+ /** A clock time as hours values write it (`9:30`, `21:00`). */
7
+ export declare const CLOCK_TIME: RegExp;
6
8
  export interface OpeningHoursInput {
7
9
  weekdays?: unknown;
8
10
  weekends?: unknown;
@@ -11,6 +11,8 @@ const SHORT_TO_KEY = {
11
11
  };
12
12
  /** The value an `openingHours` bucket uses for a day open around the clock. */
13
13
  export const HOURS_ALWAYS_OPEN = '24h';
14
+ /** A clock time as hours values write it (`9:30`, `21:00`). */
15
+ export const CLOCK_TIME = /^\d{1,2}:\d{2}$/;
14
16
  /**
15
17
  * Splits a (possibly split-shift) bucket value such as `"13:00-16:00, 20:00-23:30"` into one pair per shift.
16
18
  * A shift whose halves are not both clock times is dropped (SLA-2303); `24h` spans the whole day.
@@ -27,8 +29,8 @@ export function parseHoursShifts(value) {
27
29
  return { opens: opens?.trim(), closes: closes?.trim() };
28
30
  })
29
31
  .filter((shift) => Boolean(shift.opens && shift.closes)
30
- && /^\d{1,2}:\d{2}$/.test(shift.opens)
31
- && /^\d{1,2}:\d{2}$/.test(shift.closes));
32
+ && CLOCK_TIME.test(shift.opens)
33
+ && CLOCK_TIME.test(shift.closes));
32
34
  }
33
35
  /** Days a free-text `closed` field names ("Tuesdays", "Monday and Sunday"), in Monday-first order. */
34
36
  export function closedFieldDays(closed) {
@@ -1,10 +1,9 @@
1
1
  // Reader-facing hours on resolveOpeningHours, the JSON-LD's day resolution; values stay as written (SLA-3023).
2
- import { DAY_KEYS, HOURS_ALWAYS_OPEN, resolveOpeningHours } from "./hours.js";
2
+ import { CLOCK_TIME, DAY_KEYS, HOURS_ALWAYS_OPEN, resolveOpeningHours } from "./hours.js";
3
3
  const SHORT = {
4
4
  monday: 'Mon', tuesday: 'Tue', wednesday: 'Wed', thursday: 'Thu', friday: 'Fri', saturday: 'Sat', sunday: 'Sun',
5
5
  };
6
6
  const DAY_INDEX = Object.fromEntries(DAY_KEYS.map((d, i) => [d, i]));
7
- const HHMM = /^\d{1,2}:\d{2}$/;
8
7
  const RANGE_SEP = /\s*[-–]\s*/;
9
8
  function displayValue(raw) {
10
9
  const v = raw.trim();
@@ -86,7 +85,7 @@ function minutes(hhmm) {
86
85
  // 22:30-05:00 close above a 22:30-07:00 one.
87
86
  function closeRank(open, close) {
88
87
  const c = minutes(close);
89
- if (open && HHMM.test(open))
88
+ if (open && CLOCK_TIME.test(open))
90
89
  return c <= minutes(open) ? c + 1440 : c;
91
90
  return c;
92
91
  }
@@ -108,7 +107,7 @@ export function latestClosing(h) {
108
107
  continue;
109
108
  const shifts = raw.split(',').map((s) => s.trim()).filter(Boolean);
110
109
  const [open, close] = (shifts[shifts.length - 1] ?? '').split(RANGE_SEP).map((s) => s.trim());
111
- if (!close || !HHMM.test(close))
110
+ if (!close || !CLOCK_TIME.test(close))
112
111
  continue;
113
112
  const rank = closeRank(open, close);
114
113
  if (rank > bestRank) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sarimarcus/content-sites-core",
3
- "version": "0.38.0",
3
+ "version": "0.39.0",
4
4
  "description": "Non-visual utilities, Astro config builders and SEO schema assembly shared by the content sites.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -16,6 +16,8 @@ const SHORT_TO_KEY: Record<string, DayKey> = {
16
16
 
17
17
  /** The value an `openingHours` bucket uses for a day open around the clock. */
18
18
  export const HOURS_ALWAYS_OPEN = '24h';
19
+ /** A clock time as hours values write it (`9:30`, `21:00`). */
20
+ export const CLOCK_TIME = /^\d{1,2}:\d{2}$/;
19
21
 
20
22
  export interface OpeningHoursInput {
21
23
  weekdays?: unknown;
@@ -48,8 +50,8 @@ export function parseHoursShifts(value: string): Array<{ opens: string; closes:
48
50
  })
49
51
  .filter((shift): shift is { opens: string; closes: string } =>
50
52
  Boolean(shift.opens && shift.closes)
51
- && /^\d{1,2}:\d{2}$/.test(shift.opens)
52
- && /^\d{1,2}:\d{2}$/.test(shift.closes));
53
+ && CLOCK_TIME.test(shift.opens)
54
+ && CLOCK_TIME.test(shift.closes));
53
55
  }
54
56
 
55
57
  /** Days a free-text `closed` field names ("Tuesdays", "Monday and Sunday"), in Monday-first order. */
@@ -1,5 +1,5 @@
1
1
  // Reader-facing hours on resolveOpeningHours, the JSON-LD's day resolution; values stay as written (SLA-3023).
2
- import { DAY_KEYS, HOURS_ALWAYS_OPEN, resolveOpeningHours, type DayKey } from './hours.ts';
2
+ import { CLOCK_TIME, DAY_KEYS, HOURS_ALWAYS_OPEN, resolveOpeningHours, type DayKey } from './hours.ts';
3
3
 
4
4
  export type OpeningHours = {
5
5
  weekdays?: string;
@@ -24,7 +24,6 @@ const SHORT: Record<DayKey, string> = {
24
24
  monday: 'Mon', tuesday: 'Tue', wednesday: 'Wed', thursday: 'Thu', friday: 'Fri', saturday: 'Sat', sunday: 'Sun',
25
25
  };
26
26
  const DAY_INDEX = Object.fromEntries(DAY_KEYS.map((d, i) => [d, i])) as Record<DayKey, number>;
27
- const HHMM = /^\d{1,2}:\d{2}$/;
28
27
  const RANGE_SEP = /\s*[-–]\s*/;
29
28
 
30
29
  function displayValue(raw: string): string {
@@ -109,7 +108,7 @@ function minutes(hhmm: string): number {
109
108
  // 22:30-05:00 close above a 22:30-07:00 one.
110
109
  function closeRank(open: string | undefined, close: string): number {
111
110
  const c = minutes(close);
112
- if (open && HHMM.test(open)) return c <= minutes(open) ? c + 1440 : c;
111
+ if (open && CLOCK_TIME.test(open)) return c <= minutes(open) ? c + 1440 : c;
113
112
  return c;
114
113
  }
115
114
 
@@ -130,7 +129,7 @@ export function latestClosing(h: OpeningHours | undefined | null): { time: strin
130
129
  if (!raw || raw === HOURS_ALWAYS_OPEN) continue;
131
130
  const shifts = raw.split(',').map((s) => s.trim()).filter(Boolean);
132
131
  const [open, close] = (shifts[shifts.length - 1] ?? '').split(RANGE_SEP).map((s) => s.trim());
133
- if (!close || !HHMM.test(close)) continue;
132
+ if (!close || !CLOCK_TIME.test(close)) continue;
134
133
  const rank = closeRank(open, close);
135
134
  if (rank > bestRank) {
136
135
  bestRank = rank;