Back out ISO time

This commit is contained in:
Odd Stråbø 2024-12-21 02:59:03 +01:00
parent 3c394bc02c
commit 8d1ae2ea78
2 changed files with 9 additions and 22 deletions

View file

@ -179,12 +179,7 @@ class HTTP(object):
else: else:
try: try:
# Prefer custom Server-Time header in ISO 8601 format self.config.data["server-time"] = r.headers.get("Date")
# TODO: Clean up once the probability of most users having
# the updated server-side plugin is high.
self.config.data["server-time"] = r.headers.get(
"Server-Time", r.headers.get("Date")
)
elapsed = int(r.elapsed.total_seconds() * 1000) elapsed = int(r.elapsed.total_seconds() * 1000)
response = r.json() response = r.json()
LOG.debug("---<[ http ][%s ms]", elapsed) LOG.debug("---<[ http ][%s ms]", elapsed)

View file

@ -526,16 +526,8 @@ class Library(threading.Thread):
def save_last_sync(self): def save_last_sync(self):
_raw_time = self.server.config.data["server-time"] _raw_time = self.server.config.data["server-time"]
# The ISO 8601 header always end with Z
if _raw_time and _raw_time[-1] == "Z":
time_now = datetime.strptime(_raw_time, "%Y-%m-%dT%H:%M:%SZ")
else:
try: try:
# TODO: Clean up once the probability of most users having
# the updated server-side plugin is high.
LOG.warning(
"Server time not in ISO 8601 format, using fallback (update KodiSyncQueue)."
)
import email.utils import email.utils
time_now = email.utils.parsedate_to_datetime(_raw_time) time_now = email.utils.parsedate_to_datetime(_raw_time)