File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @repo/mcp-common ' : minor
3+ ---
4+
5+ add relative timeframe support for querying
Original file line number Diff line number Diff line change @@ -16,7 +16,13 @@ export function parseRelativeTime(input: string): number {
1616 const sign = cleanedInput . startsWith ( '-' ) ? - 1 : 1
1717
1818 const timeStr = cleanedInput . slice ( 1 ) // Remove the sign
19- const seconds = timeStr . match ( / \d + [ s m h d w ] / g) ! . reduce ( ( total , match ) => {
19+ const matches = timeStr . match ( / \d + [ s m h d w ] / g)
20+
21+ if ( ! matches ) {
22+ throw new Error ( `This shouldn't ever happen, but no matches found in: ${ timeStr } ` )
23+ }
24+
25+ const seconds = matches . reduce ( ( total , match ) => {
2026 const value = parseInt ( match )
2127 const unit = match . slice ( - 1 ) as keyof typeof units
2228
You can’t perform that action at this time.
0 commit comments