v0.3.1
What's new
Time-aware routes now accept an optional ?date=YYYY-MM-DD query parameter to pin the response to a historical date.
/now?date=2012-02-02— wall-clock HH:MM stays current; the calendar / weekday strip / year-progress caption all reflect the override day./stock?date=2012-02-02— loads the latest stock data on or before the date (closest completed trading session). Live breadth is skipped on historical lookups; the closed-market enrichment block (positioning + breadth + credit, on the TW path) renders unconditionally.
Invalid ?date= values fall through silently to the live path, matching the existing behavior of ?format= and ?region=.
Implementation notes
- New middleware
DateOverrideDetectorparses the override strictly withtime.ParseInLocationagainst the caller's resolved location — middleware order pinnedTimezoneDetector → DateOverrideDetector → …inserver.New(). - New helpers
middleware.GetDate(c)andmiddleware.NowFor(c)— any future time-aware service consumes them for free. - Optional
quote.HistoricalProviderandtwse.HistoricalProviderinterfaces (mirroring the existingLiveBreadthProviderpattern) avoid breaking-change to existingProviderimplementations. - Yahoo
GetAtuses a narrowperiod1/period2window (asOf-14d → asOf+1d) and walks indicator timestamps backwards to the latest bar at-or-before end-of-asOf-day;IsClosedforced true for historical bars. - Future-dated
asOfclamped totime.Now()defensively in both providers. - Cached layers passthrough on historical lookups (no date-keyed cache).
Test coverage
- Middleware: explicit override, invalid date fall-through, timezone interaction, no-middleware safety.
/now: override shifts caption; invalid date falls through.quote/yahoo: latest-bar-at-or-before pick, future clamp, empty-window handling.quote/cached: bypasses live cache for historical, ErrUnavailable when inner is not historical.twse: walk-back from asOf, future clamp, cache bypass, ErrUnavailable when inner is not historical./stock: GetAt routing under override, TW path skips live breadth and live Get, invalid date fall-through.