MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / _normalize_expiry

Function _normalize_expiry

scripts/website/export_storage_state.py:181–193  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

179
180
181def _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
196def main(argv: list[str]) -> int:

Callers 1

_firefox_storage_stateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected