Skip to contents

Both APIs report timestamps as ISO 8601 with a T separator, microseconds and a Z suffix (e.g. "2026-08-20T02:42:43.000000Z", measured against marks.spdgt.com). None of as.POSIXct()'s default formats match that: it tries the space-separated ones, fails, then falls back to "%Y-%m-%d", which matches the leading date and silently discards the time. A token expiring at 02:42 was therefore stored as midnight, and auth_status() reported a live token as expired.

Usage

parse_api_datetime(x)

Arguments

x

A timestamp string from an API response, or an existing POSIXct.

Value

POSIXct in UTC. NULL when x is absent or does not parse — NULL rather than NA because a missing expiration reads as "no expiration" everywhere it is used, while NA would break the exp < Sys.time() comparison in auth_status().

Details

An offset is the same fault one layer up. strptime() stops once a format is satisfied and ignores what follows, so "...T02:42:43-06:00" parsed as 02:42 UTC rather than 08:42 – a confident answer six hours wrong. Two shapes need normalising before %z can read them: Z is an offset that is not spelled like one, and %z rejects the colon ISO 8601 puts in +HH:MM. Neither API sends an offset today, so this is a guard, not a repair.