@cdx-ui/formatters 0.1.2
“”
Calls an expect assertion matcherConstructs locale-aware date and time formatter
SHA-25642694c98b372b89e6d6e77dbc7b38e7e82b0f52e303e9b05f05afcc0cb4b1571
MaleculeH(Db₃)Md(Pa)
Evidence
⋯4 lines
5});
6exports.dateId = dateId;
7var _brand = require("../internal/brand");
8var _formatDateId = require("./formatDateId");
9var _isValidDateId = require("./isValidDateId");
10var _isValidDateParts = require("./isValidDateParts");
11/**
12 * Validating smart constructor for a wire {@link DateId} (`YYYY-MM-DD`).
13 *
14 * Accepts either a wire string or numeric parts. Throws `RangeError` on input
15 * that is not a real calendar date — use this at the boundary where you first
16 * introduce a date value so a bad id never enters your form state.
17 *
⋯26 lines
44 };
45 if (!(0, _isValidDateParts.isValidDateParts)(parts)) {
46 throw new RangeError(`Invalid DateId parts: ${JSON.stringify(parts)}.`);
47 }
48 return (0, _brand.asDateId)((0, _formatDateId.formatDateId)(parts));
⋯5 lines
6exports.isLocaleHour12 = isLocaleHour12;
7/**
8 * Whether the given locale conventionally uses a 12-hour clock (AM/PM).
9 *
10 * Derived from the locale's resolved hour cycle so date-time components can
⋯6 lines
17function isLocaleHour12(locale) {
18 try {
19 const resolved = new Intl.DateTimeFormat(locale ?? 'en-US', {
20 hour: 'numeric'
21 }).resolvedOptions();
⋯6 lines
28 }
29}
30//# sourceMappingURL=isLocaleHour12.js.map
28:32… el (AM/PM or locale equivalent) for a 0–23 hour value. */
29function formatDayPeriodFromHour(hour, …
⋯21 lines
70 return ' – ';
71}
72//# sourceMappingURL=intlCopy.js.map
1import { getDateTimeFieldSegments } from '../dates/segments/getDateTimeFieldSegments';
2
3describe('getDateTimeFieldSegments', () => {
4 it('returns placeholder date-time segments when value is empty', () => {
5 const segments = getDateTimeFieldSegments(undefined, {
6 granularity: 'minute',
7 locale: 'en-US',
8 hour12: true,
9 });
10 expect(segments.find((s) => s.type === 'month')?.text).toBe('MM');
11 expect(segments.find((s) => s.type === 'hour')?.text).toBe('hh');
12 expect(segments.find((s) => s.type === 'hour')?.value).toBeUndefined();
13 expect(segments.find((s) => s.type === 'minute')?.text).toBe('mm');
14 expect(segments.find((s) => s.type === 'dayPeriod')?.text).toBe('AM');
15 });
16
17 it('returns 12-hour date-time field segments with day period', () => {
18 const segments = getDateTimeFieldSegments('2026-07-28T14:30', {
19 …
Showing the top 5 files — 3 more files (7 regions) not shown.
No evidence locations were recorded for this file. Raw result