MCPcopy Index your code
hub / github.com/JavaScriptRegenerated/yieldparser / TimeOfDayParser

Function TimeOfDayParser

src/natural-dates.test.ts:58–68  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

56 }
57
58 function* TimeOfDayParser() {
59 let hours = yield ParseInt;
60 const minutes = yield optional(MinutesSuffixParser);
61 const amOrPm = yield optional('am', 'pm');
62 if (amOrPm === 'pm' && hours <= 11) {
63 hours += 12;
64 } else if (amOrPm === 'am' && hours === 12) {
65 hours = 24;
66 }
67 return { hours, minutes };
68 }
69
70 function* TimespanSuffixParser() {
71 const started = yield optional('to', '-', '–', '—', 'until');

Callers

nothing calls this directly

Calls 1

optionalFunction · 0.90

Tested by

no test coverage detected