Fix iOS date: st_mtime is datetime.datetime object, use isoformat() directly

This commit is contained in:
Kyle Bolen
2026-07-28 08:33:36 +00:00
parent fa2e95bb45
commit f739114f7d

View File

@@ -94,13 +94,14 @@ async def cmd_list_photos():
print(f'DEBUG stat: {dict(info)}', file=sys.stderr)
debug_logged = True
size_bytes = int(info.get('st_size', 0))
# Use 'datetime' tuple: (year, month, day, hour, minute, second, microsecond)
dt = info.get('datetime')
if dt is not None and isinstance(dt, (list, tuple)) and len(dt) >= 6:
date_iso = datetime(int(dt[0]), int(dt[1]), int(dt[2]),
int(dt[3]), int(dt[4]), int(dt[5])).isoformat()
elif dt is not None and hasattr(dt, 'isoformat'):
date_iso = dt.isoformat()
# st_mtime is a datetime.datetime object in this version
dt = info.get('st_mtime') or info.get('datetime') or info.get('st_birthtime')
if dt is not None:
if hasattr(dt, 'isoformat'):
date_iso = dt.isoformat()
elif isinstance(dt, (list, tuple)) and len(dt) >= 6:
date_iso = datetime(int(dt[0]), int(dt[1]), int(dt[2]),
int(dt[3]), int(dt[4]), int(dt[5])).isoformat()
except Exception:
pass