MCPcopy
hub / github.com/promptfoo/promptfoo / parseHttpDate

Function parseHttpDate

src/scheduler/headerParser.ts:190–201  ·  view source on GitHub ↗

* Parse HTTP-date format (RFC 7231).

(value: string)

Source from the content-addressed store, hash-verified

188 * Parse HTTP-date format (RFC 7231).
189 */
190function parseHttpDate(value: string): number | null {
191 const timestamp = Date.parse(value);
192 if (!isNaN(timestamp)) {
193 // Sanity check: within reasonable range (not too far past or future)
194 const now = Date.now();
195 const oneYearMs = 365 * 24 * 60 * 60 * 1000;
196 if (timestamp > now - oneYearMs && timestamp < now + oneYearMs) {
197 return timestamp;
198 }
199 }
200 return null;
201}
202
203/**
204 * Parse duration strings like "1s", "100ms", "1m30s", "1h30s", "2h15m30s".

Callers 2

parseRetryAfterFunction · 0.85
parseResetTimeFunction · 0.85

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…