httpDate function

String httpDate()

The Date header value for now, an RFC 9110 5.6.7 IMF-fixdate.

A stopwatch decides when to read the wall clock, once per second at the second boundary. A response pays a stopwatch read, not a clock read and a format.

Time comes from package:clock, so a test or a simulation that runs under withClock gets its own dates. The cache is per clock. The system clock gets a dart:core Stopwatch, a monotonic counter read. A substituted clock gets its own stopwatch, which reads that clock's now on every elapsed read, so the cache follows the clock it is told.

Implementation

String httpDate() {
  _refresh();
  return _value;
}