@sarimarcus/content-sites-core 0.52.1 → 0.53.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,10 @@
2
2
 
3
3
  All packages in the platform release in lockstep; entries are per release version.
4
4
 
5
+ ## 0.53.0 (2026-10-29)
6
+
7
+ - `dates`: new `formatDisplayDay(iso, locale, timeZone)`, the day a reader sees: a stamp's day in `timeZone`, a date-only value's UTC day, never the hour (SLA-3590).
8
+
5
9
  ## 0.52.1 (2026-10-28)
6
10
 
7
11
  - Lockstep release, no change (SLA-3566).
@@ -11,6 +11,12 @@
11
11
  * @param locale BCP-47 locale (default en-US)
12
12
  */
13
13
  export declare function formatUtcDate(iso: string | undefined, options?: Intl.DateTimeFormatOptions, locale?: string): string;
14
+ /**
15
+ * Format a stamp as the calendar day a reader sees, long form ("2 April 2026" for `en-GB`). A value that carries a
16
+ * time prints its day in `timeZone` (so 23:30 UTC is already the next day in Madrid); a date-only value prints its
17
+ * UTC day, as `formatUtcDate` does. The hour is never printed. Partial or unparseable input returns ''.
18
+ */
19
+ export declare function formatDisplayDay(iso: string | undefined, locale?: string, timeZone?: string): string;
14
20
  /**
15
21
  * Format a `startDate`/`endDate` pair as a compact display range, UTC-anchored
16
22
  * via `formatUtcDate`: "Aug 12" (single day), "Aug 12–13" (same month),
@@ -20,6 +20,20 @@ export function formatUtcDate(iso, options = { month: 'long', day: 'numeric' },
20
20
  return '';
21
21
  return date.toLocaleDateString(locale, { ...options, timeZone: 'UTC' });
22
22
  }
23
+ /**
24
+ * Format a stamp as the calendar day a reader sees, long form ("2 April 2026" for `en-GB`). A value that carries a
25
+ * time prints its day in `timeZone` (so 23:30 UTC is already the next day in Madrid); a date-only value prints its
26
+ * UTC day, as `formatUtcDate` does. The hour is never printed. Partial or unparseable input returns ''.
27
+ */
28
+ export function formatDisplayDay(iso, locale = 'en-GB', timeZone = 'UTC') {
29
+ if (!iso || iso.length < 10)
30
+ return '';
31
+ const hasTime = iso.includes('T');
32
+ const date = new Date(hasTime ? iso : `${iso.slice(0, 10)}T00:00:00Z`);
33
+ if (Number.isNaN(date.getTime()))
34
+ return '';
35
+ return date.toLocaleDateString(locale, { year: 'numeric', month: 'long', day: 'numeric', timeZone: hasTime ? timeZone : 'UTC' });
36
+ }
23
37
  /**
24
38
  * Format a `startDate`/`endDate` pair as a compact display range, UTC-anchored
25
39
  * via `formatUtcDate`: "Aug 12" (single day), "Aug 12–13" (same month),
@@ -1,4 +1,4 @@
1
- export { formatUtcDate, formatUtcDateRange } from './formatDate.ts';
1
+ export { formatUtcDate, formatUtcDateRange, formatDisplayDay } from './formatDate.ts';
2
2
  export { buildNow } from './buildClock.ts';
3
3
  export { maxDate, latestDateModified, NEW_BADGE_DAYS, isNew } from './lastmod.ts';
4
4
  export { eventToIcs, eventsToIcs, googleCalendarUrl, monthsCovered } from './ics.ts';
@@ -1,5 +1,5 @@
1
1
  // Public surface of @sarimarcus/content-sites-core/dates.
2
- export { formatUtcDate, formatUtcDateRange } from "./formatDate.js";
2
+ export { formatUtcDate, formatUtcDateRange, formatDisplayDay } from "./formatDate.js";
3
3
  export { buildNow } from "./buildClock.js";
4
4
  export { maxDate, latestDateModified, NEW_BADGE_DAYS, isNew } from "./lastmod.js";
5
5
  export { eventToIcs, eventsToIcs, googleCalendarUrl, monthsCovered } from "./ics.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sarimarcus/content-sites-core",
3
- "version": "0.52.1",
3
+ "version": "0.53.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",
@@ -23,6 +23,19 @@ export function formatUtcDate(
23
23
  return date.toLocaleDateString(locale, { ...options, timeZone: 'UTC' });
24
24
  }
25
25
 
26
+ /**
27
+ * Format a stamp as the calendar day a reader sees, long form ("2 April 2026" for `en-GB`). A value that carries a
28
+ * time prints its day in `timeZone` (so 23:30 UTC is already the next day in Madrid); a date-only value prints its
29
+ * UTC day, as `formatUtcDate` does. The hour is never printed. Partial or unparseable input returns ''.
30
+ */
31
+ export function formatDisplayDay(iso: string | undefined, locale: string = 'en-GB', timeZone: string = 'UTC'): string {
32
+ if (!iso || iso.length < 10) return '';
33
+ const hasTime = iso.includes('T');
34
+ const date = new Date(hasTime ? iso : `${iso.slice(0, 10)}T00:00:00Z`);
35
+ if (Number.isNaN(date.getTime())) return '';
36
+ return date.toLocaleDateString(locale, { year: 'numeric', month: 'long', day: 'numeric', timeZone: hasTime ? timeZone : 'UTC' });
37
+ }
38
+
26
39
  /**
27
40
  * Format a `startDate`/`endDate` pair as a compact display range, UTC-anchored
28
41
  * via `formatUtcDate`: "Aug 12" (single day), "Aug 12–13" (same month),
@@ -1,5 +1,5 @@
1
1
  // Public surface of @sarimarcus/content-sites-core/dates.
2
- export { formatUtcDate, formatUtcDateRange } from './formatDate.ts';
2
+ export { formatUtcDate, formatUtcDateRange, formatDisplayDay } from './formatDate.ts';
3
3
  export { buildNow } from './buildClock.ts';
4
4
  export { maxDate, latestDateModified, NEW_BADGE_DAYS, isNew } from './lastmod.ts';
5
5
  export { eventToIcs, eventsToIcs, googleCalendarUrl, monthsCovered } from './ics.ts';