MCPcopy Create free account
hub / github.com/adobe/react-spectrum / parseTime

Function parseTime

packages/@internationalized/date/src/string.ts:42–54  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

40
41/** Parses an ISO 8601 time string. */
42export function parseTime(value: string): Time {
43 let m = value.match(TIME_RE);
44 if (!m) {
45 throw new Error('Invalid ISO 8601 time string: ' + value);
46 }
47
48 return new Time(
49 parseNumber(m[1], 0, 23),
50 m[2] ? parseNumber(m[2], 0, 59) : 0,
51 m[3] ? parseNumber(m[3], 0, 59) : 0,
52 m[4] ? parseNumber(m[4], 0, Infinity) * 1000 : 0
53 );
54}
55
56/** Parses an ISO 8601 date string, with no time components. */
57export function parseDate(value: string): CalendarDate {

Callers 6

RenderFunction · 0.90
DefaultValueFunction · 0.90
HourCycle12Function · 0.90
HourCycle24Function · 0.90
ForceLeadingZerosFunction · 0.90
string.test.jsFile · 0.85

Calls 1

parseNumberFunction · 0.85

Tested by

no test coverage detected