@sarimarcus/content-sites-core 0.52.1 → 0.53.1
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 +8 -0
- package/dist/dates/formatDate.d.ts +6 -0
- package/dist/dates/formatDate.js +14 -0
- package/dist/dates/index.d.ts +1 -1
- package/dist/dates/index.js +1 -1
- package/package.json +1 -1
- package/src/dates/formatDate.ts +13 -0
- package/src/dates/index.ts +1 -1
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.53.1 (2026-10-29)
|
|
6
|
+
|
|
7
|
+
- Lockstep release, no change (SLA-3604).
|
|
8
|
+
|
|
9
|
+
## 0.53.0 (2026-10-29)
|
|
10
|
+
|
|
11
|
+
- `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).
|
|
12
|
+
|
|
5
13
|
## 0.52.1 (2026-10-28)
|
|
6
14
|
|
|
7
15
|
- 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),
|
package/dist/dates/formatDate.js
CHANGED
|
@@ -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),
|
package/dist/dates/index.d.ts
CHANGED
|
@@ -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';
|
package/dist/dates/index.js
CHANGED
|
@@ -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
package/src/dates/formatDate.ts
CHANGED
|
@@ -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),
|
package/src/dates/index.ts
CHANGED
|
@@ -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';
|