Simplify iOS date parsing: use datetime tuple, confirmed working format
This commit is contained in:
@@ -94,22 +94,13 @@ async def cmd_list_photos():
|
|||||||
print(f'DEBUG stat: {dict(info)}', file=sys.stderr)
|
print(f'DEBUG stat: {dict(info)}', file=sys.stderr)
|
||||||
debug_logged = True
|
debug_logged = True
|
||||||
size_bytes = int(info.get('st_size', 0))
|
size_bytes = int(info.get('st_size', 0))
|
||||||
# pymobiledevice3 returns 'datetime' as a tuple:
|
# Use 'datetime' tuple: (year, month, day, hour, minute, second, microsecond)
|
||||||
# (year, month, day, hour, minute, second, microsecond)
|
|
||||||
dt = info.get('datetime')
|
dt = info.get('datetime')
|
||||||
if dt is not None:
|
if dt is not None and isinstance(dt, (list, tuple)) and len(dt) >= 6:
|
||||||
if hasattr(dt, 'isoformat'):
|
date_iso = datetime(int(dt[0]), int(dt[1]), int(dt[2]),
|
||||||
date_iso = dt.isoformat()
|
int(dt[3]), int(dt[4]), int(dt[5])).isoformat()
|
||||||
elif isinstance(dt, (list, tuple)) and len(dt) >= 6:
|
elif dt is not None and hasattr(dt, 'isoformat'):
|
||||||
date_iso = datetime(int(dt[0]), int(dt[1]), int(dt[2]),
|
date_iso = dt.isoformat()
|
||||||
int(dt[3]), int(dt[4]), int(dt[5])).isoformat()
|
|
||||||
else:
|
|
||||||
# Fallback: try st_mtime as integer timestamp
|
|
||||||
mtime_raw = int(info.get('st_mtime', 0))
|
|
||||||
if mtime_raw > 1_000_000_000_000_000:
|
|
||||||
mtime_raw = mtime_raw // 1_000_000_000
|
|
||||||
if mtime_raw > 1_000_000_000:
|
|
||||||
date_iso = datetime.fromtimestamp(float(mtime_raw)).isoformat()
|
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user