mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-19 16:03:00 +00:00
indicate that REST API timestamps are UTC
use iso8601 Z suffix for UTC timestamps use dateutil to parse dates from proxy, as well even though CHP uses iso8601 UTC timestamps, we no longer assume CHP, so use more general parsing in our db we are stuck with naïve datetime objects, so use those internally. But ensure we put 'Z' on timestamps we ship externally
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
import asyncio
|
||||
from binascii import b2a_hex
|
||||
import concurrent.futures
|
||||
from datetime import datetime, timezone
|
||||
import random
|
||||
import errno
|
||||
import hashlib
|
||||
@@ -15,7 +16,6 @@ import os
|
||||
import socket
|
||||
import sys
|
||||
import threading
|
||||
from threading import Thread
|
||||
import uuid
|
||||
import warnings
|
||||
|
||||
@@ -39,6 +39,16 @@ ISO8601_ms = '%Y-%m-%dT%H:%M:%S.%fZ'
|
||||
ISO8601_s = '%Y-%m-%dT%H:%M:%SZ'
|
||||
|
||||
|
||||
def isoformat(dt):
|
||||
"""Render a datetime object as an ISO 8601 UTC timestamp
|
||||
|
||||
Naïve datetime objects are assumed to be UTC
|
||||
"""
|
||||
if dt.tzinfo:
|
||||
dt = dt.astimezone(timezone.utc).replace(tzinfo=None)
|
||||
return dt.isoformat() + 'Z'
|
||||
|
||||
|
||||
def can_connect(ip, port):
|
||||
"""Check if we can connect to an ip:port.
|
||||
|
||||
|
Reference in New Issue
Block a user