Manage microseconds in JSON-RPC

review3501003
This commit is contained in:
Cédric Krier committed 2014-03-15 10:38:44 +01:00
1 parent ca0023f8af
commit 7710ce2c61
2 files changed
+6 -2

No files matched your search

+1
View File
@@ -28,6 +28,7 @@ MAPPING = {
'%M': ('__', '([_ 0-9][_ 0-9])'),
'%S': ('__', '([_ 0-9][_ 0-9])'),
'%p': ('__', '([_ AP][_ M])'),
'%f': ('______', '([_0-9][_0-9][_0-9][_0-9][_0-9][_0-9])'),
}
OPERATORS = {
gtk.keysyms.S: relativedelta(seconds=-1),
+5 -2
View File
@@ -49,11 +49,12 @@ def object_hook(dct):
if '__class__' in dct:
if dct['__class__'] == 'datetime':
return datetime.datetime(dct['year'], dct['month'], dct['day'],
dct['hour'], dct['minute'], dct['second'])
dct['hour'], dct['minute'], dct['second'], dct['microsecond'])
elif dct['__class__'] == 'date':
return datetime.date(dct['year'], dct['month'], dct['day'])
elif dct['__class__'] == 'time':
return datetime.time(dct['hour'], dct['minute'], dct['second'])
return datetime.time(dct['hour'], dct['minute'], dct['second'],
dct['microsecond'])
elif dct['__class__'] == 'buffer':
return buffer(base64.decodestring(dct['base64']))
elif dct['__class__'] == 'Decimal':
@@ -78,6 +79,7 @@ class JSONEncoder(json.JSONEncoder):
'hour': obj.hour,
'minute': obj.minute,
'second': obj.second,
'microsecond': obj.microsecond,
}
return {'__class__': 'date',
'year': obj.year,
@@ -89,6 +91,7 @@ class JSONEncoder(json.JSONEncoder):
'hour': obj.hour,
'minute': obj.minute,
'second': obj.second,
'microsecond': obj.microsecond,
}
elif isinstance(obj, buffer):
return {'__class__': 'buffer',