import calendar import time STAMP = "%Y-%m-%dT%H:%M:%SZ" STAMPED = r"\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ" def utc(at: float) -> str: return time.strftime(STAMP, time.gmtime(at)) def seconds(stamp: str) -> int: """The seconds since the epoch that stamp names, read in utc's format. Raises ValueError where time.strptime cannot read it so.""" return calendar.timegm(time.strptime(stamp, STAMP))