kinetex - v1.0.0-rc.1
    Preparing search index...

    Function parseCookieDate

    • Parse a cookie date string per RFC 6265 §5.1.1

      Parameters

      • dateStr: string

        The date string to parse

      Returns number | null

      Unix timestamp (ms) if valid, null otherwise

      Supported formats (per RFC 6265 §5.1.1 and real-world broken variants):

      Format Example
      HTTP-date (RFC 5322) "Thu, 01 Jan 2099 00:00:00 GMT"
      RFC 850 "Thursday, 01-Jan-99 00:00:00 GMT"
      ANSI C asctime() "Thu Jan 1 00:00:00 2099"
      Short numeric "01/01/2099 00:00:00"
      Cookie spec (RFC 2109) "Thu, 01-Jan-2099 00:00:00 GMT"
      Broken variants (lenient) Various real-world malformed dates

      Algorithm:

      1. Tokenize input into time, month, day-of-month, year tokens
      2. Extract time component (HH:MM:SS format)
      3. Extract month (3-letter or full name)
      4. Extract day-of-month (1-31)
      5. Extract year (2-digit with RFC 6265 §5.1.1 step 3 mapping, or 4-digit)
      6. Validate: year must be 1601-9999, day must be 1-31
      7. Return UTC timestamp or null if invalid

      Notes:

      • Two-digit years are mapped: 00-69 → 2000-2069, 70-99 → 1970-1999
      • Lenient on whitespace and minor format variations
      • Returns null for dates with missing components or invalid ranges