dateRange()

True if the current date is within the given day, month and/or year range.

dateRange(day | month | year ... [, "GMT"])  →  boolean

Not used in the real PAC files of the PAC file statistics.

Accepts many argument forms (day, month, year, or ranges of them). Local time unless “GMT” is the last argument.

Example

if (dateRange("DEC", "JAN")) {
  return "PROXY proxy-holiday.corp.example:8080";
}

A date range across the new year matches in the browsers but not in pactester

dateRange("DEC", "JAN") wraps around the new year in Chrome, Edge and Firefox. pactester (pacparser) never matches such a range, so the example above would never pick the holiday proxy in a pactester test. dateRange("DEC") || dateRange("JAN") works the same in Chrome, Edge, Firefox and pactester. The PAC file tester flags ranges like this.

dateRange is never true on Windows

In Windows (WinHTTP) dateRange returned false for every one of the fourteen argument forms tried, including dateRange(1, 31) and the current year. A branch that depends on it never runs for Windows programs. If the date matters, make the decision on the proxy instead. Paste your file into the PAC file tester and pick the Windows (WinHTTP) profile to see the Windows answer.

Check how your own file behaves with the PAC file tester: switch the engine profile between Chromium, Firefox, pacparser and Windows and compare the trace. All engine differences are collected in pactester vs Chrome and Firefox.

Engine notes

EngineBehaviourSource
chromiumSupports wrap-around ranges such as DEC to JAN.lab, verified 2026-10-11
services/proxy_resolver/pac_js_library.h@cb6eb0e7
firefoxSupports wrap-around ranges.lab, verified 2026-10-11
netwerk/base/ascii_pac_utils.js@3f73c528
pacparserNo wrap-around ranges.lab, verified 2026-10-11
src/pac_utils.h@v1.5.3
winhttpAlways false, whatever the arguments (14 forms tested, including dateRange(1, 31) and the current year).lab, verified 2026-10-11
Windows 11 25H2

Availability

Derived from each engine's vendored helper library plus its native bindings (see engines).
Functionchromium
<=51
chromium
>=52
firefox
all
pacparser
<=1.4.6
pacparser
>=1.5.1
winhttp
11-25H2
wininet
11-25H2
reference
all
dateRangeyesyesyesyesyesyesyesyes

Related rules

Frequently asked questions

Does dateRange("DEC", "JAN") work across the new year?

In Chrome, Edge and Firefox it does. In pactester (pacparser) it never matches. Split it into dateRange("DEC") || dateRange("JAN") to get the same answer in those engines. On Windows (WinHTTP) dateRange is never true at all.

Why does dateRange never match on Windows?

Windows (WinHTTP) returns false from dateRange whatever the arguments are, so the date branch of a PAC file never runs in Windows programs. Splitting the range does not help. Move the date-dependent decision to the proxy, or write the file so that its result does not depend on the date.

Last updated: