PAC-K007 · time-functions-usage

Time-based routing (weekdayRange, dateRange, timeRange)

low · Compatibility across engines

Time-based routing depends on the client's clock and timezone and on helper implementations that differ between engines in argument handling. Behaviour is hard to test and hard to reproduce in support cases.

Why it matters

weekdayRange("MON", "FRI") and timeRange(9, 17) are evaluated with the client’s local time unless "GMT" is passed, so laptops in other timezones, wrong clocks and daylight saving transitions change routing. The engines’ implementations also differ in details such as accepted argument forms. The business need (different proxy outside office hours, a maintenance window) is usually better served on the proxy side. Draft until the lab has recorded the per-engine differences.

How to fix

Move time-dependent policy to the proxy; if the PAC must do it, pass "GMT" explicitly and test on every target engine.

Examples

Bad

function FindProxyForURL(url, host) {
  if (weekdayRange("MON", "FRI") && timeRange(8, 18)) {
    return "PROXY proxy.corp.example:8080";
  }
  return "PROXY backup.corp.example:8080";
}
Open bad example in checker

Good

function FindProxyForURL(url, host) {
  return "PROXY proxy.corp.example:8080; PROXY backup.corp.example:8080";
}
Open good example in checker

Related rules

References