Coerce a Firefox cookies.sqlite expiry into a Playwright-acceptable value. Playwright wants seconds-since-epoch (positive number) or -1 for session. Firefox stores `expiry` in seconds in older code but in milliseconds in newer entries. Anything past ~year 5138 must be milliseconds — div
(raw: float | int | None)
| 179 | |
| 180 | |
| 181 | def _normalize_expiry(raw: float | int | None) -> float: |
| 182 | """Coerce a Firefox cookies.sqlite expiry into a Playwright-acceptable value. |
| 183 | |
| 184 | Playwright wants seconds-since-epoch (positive number) or -1 for session. |
| 185 | Firefox stores `expiry` in seconds in older code but in milliseconds in |
| 186 | newer entries. Anything past ~year 5138 must be milliseconds — divide. |
| 187 | """ |
| 188 | if not raw: |
| 189 | return -1.0 |
| 190 | value = float(raw) |
| 191 | if value > 1e11: # > ~year 5138 in seconds; treat as milliseconds. |
| 192 | value = value / 1000.0 |
| 193 | return value |
| 194 | |
| 195 | |
| 196 | def main(argv: list[str]) -> int: |
no outgoing calls
no test coverage detected