MCPcopy Index your code
hub / github.com/sourcebot-dev/sourcebot / toGitDate

Function toGitDate

packages/web/src/features/git/dateUtils.ts:164–186  ·  view source on GitHub ↗
(dateStr: string | undefined)

Source from the content-addressed store, hash-verified

162 * @returns Git-compatible date string or undefined
163 */
164export function toGitDate(dateStr: string | undefined): string | undefined {
165 if (!dateStr) {
166 return undefined;
167 }
168
169 // Git natively understands these formats, so preserve them
170 const gitNativeFormats = [
171 /^\d+\s+(second|minute|hour|day|week|month|year)s?\s+ago$/i,
172 /^yesterday$/i,
173 /^last\s+(week|month|year)$/i,
174 /^\d{4}-\d{2}-\d{2}$/, // ISO date
175 /^\d{4}-\d{2}-\d{2}T/, // ISO datetime
176 ];
177
178 for (const pattern of gitNativeFormats) {
179 if (pattern.test(dateStr)) {
180 return dateStr; // Git can handle this directly
181 }
182 }
183
184 // Otherwise, parse and convert to ISO
185 return parseTemporalDate(dateStr);
186}

Callers 2

listCommitsFunction · 0.90
dateUtils.test.tsFile · 0.90

Calls 1

parseTemporalDateFunction · 0.85

Tested by

no test coverage detected