Add a gdb pretty printer for wxDateTime.
Format it using Python datetime module in the standard ISO notation. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70992 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
ce84ef6a7f
commit
14f3866748
@ -14,6 +14,7 @@
|
|||||||
# wxFoo class we want to pretty print. Then just add wxFoo to the types array
|
# wxFoo class we want to pretty print. Then just add wxFoo to the types array
|
||||||
# in wxLookupFunction at the bottom of this file.
|
# in wxLookupFunction at the bottom of this file.
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
|
||||||
# shamelessly stolen from std::string example
|
# shamelessly stolen from std::string example
|
||||||
class wxStringPrinter:
|
class wxStringPrinter:
|
||||||
@ -26,6 +27,18 @@ class wxStringPrinter:
|
|||||||
def display_hint(self):
|
def display_hint(self):
|
||||||
return 'string'
|
return 'string'
|
||||||
|
|
||||||
|
class wxDateTimePrinter:
|
||||||
|
def __init__(self, val):
|
||||||
|
self.val = val
|
||||||
|
|
||||||
|
def to_string(self):
|
||||||
|
# A value of type wxLongLong can't be used in Python arithmetic
|
||||||
|
# expressions directly so we need to convert it to long long first and
|
||||||
|
# then cast to int explicitly to be able to use it as a timestamp.
|
||||||
|
msec = self.val['m_time'].cast(gdb.lookup_type('long long'))
|
||||||
|
sec = int(msec / 1000)
|
||||||
|
return datetime.datetime.fromtimestamp(sec).isoformat(' ')
|
||||||
|
|
||||||
class wxXYPrinterBase:
|
class wxXYPrinterBase:
|
||||||
def __init__(self, val):
|
def __init__(self, val):
|
||||||
self.x = val['x']
|
self.x = val['x']
|
||||||
@ -53,7 +66,7 @@ class wxRectPrinter(wxXYPrinterBase):
|
|||||||
def wxLookupFunction(val):
|
def wxLookupFunction(val):
|
||||||
# Using a list is probably ok for so few items but consider switching to a
|
# Using a list is probably ok for so few items but consider switching to a
|
||||||
# set (or a dict and cache class types as the keys in it?) if needed later.
|
# set (or a dict and cache class types as the keys in it?) if needed later.
|
||||||
types = ['wxString', 'wxPoint', 'wxSize', 'wxRect']
|
types = ['wxString', 'wxDateTime', 'wxPoint', 'wxSize', 'wxRect']
|
||||||
|
|
||||||
for t in types:
|
for t in types:
|
||||||
if val.type.tag == t:
|
if val.type.tag == t:
|
||||||
|
Loading…
Reference in New Issue
Block a user