formatters

This commit is contained in:
2025-12-06 09:07:21 +08:00
commit 6a636f747d

14
formatters/chrono.py Normal file
View File

@@ -0,0 +1,14 @@
from datetime import datetime,timedelta
print('loading lldb chrono formatter')
def GetSummary(valobj, internal_dict):
yof = valobj.GetChildMemberWithName('datetime').GetChildMemberWithName('date').GetChildMemberWithName('yof').GetChildMemberWithName('__0').GetChildMemberWithName('__0').GetValue();
if (yof == None):
yof = valobj.GetChildMemberWithName('datetime').GetChildMemberWithName('date').GetChildMemberWithName('yof').GetChildMemberWithName('__0').GetChildMemberWithName('0').GetValue();
secs = valobj.GetChildMemberWithName('datetime').GetChildMemberWithName('time').GetChildMemberWithName('secs').GetValue();
year = int(yof) >> 13
day_of_year = (int(yof) & 8191) >> 4;
date = datetime(year -1, 12, 31) + timedelta(days=day_of_year) + timedelta(seconds=int(secs))
return date.strftime('%Y-%m-%d %H:%M:%S')