summaryrefslogtreecommitdiff
path: root/python/qpid/codec010.py
diff options
context:
space:
mode:
authorRafael H. Schloming <rhs@apache.org>2008-11-10 15:19:29 +0000
committerRafael H. Schloming <rhs@apache.org>2008-11-10 15:19:29 +0000
commit8be83d96ee667728d8a5da0db2e68e29c2177dda (patch)
tree8adb650a08d1eb5912970aa3e5142c4c74292abf /python/qpid/codec010.py
parent36a1702b48b62a9df223c1244e4ea7fbd466f771 (diff)
downloadqpid-python-8be83d96ee667728d8a5da0db2e68e29c2177dda.tar.gz
added a timestamp class to qpid.datatypes and modified codec to use it for AMQP's datetime type; this fixes support of datetime within maps where formerly decoding and reencoding the same value would switch an entry in a map from an AMQP datetime to an AMQP uint64
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@712673 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/qpid/codec010.py')
-rw-r--r--python/qpid/codec010.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/python/qpid/codec010.py b/python/qpid/codec010.py
index c2ea7ed512..f34025ef17 100644
--- a/python/qpid/codec010.py
+++ b/python/qpid/codec010.py
@@ -17,8 +17,9 @@
# under the License.
#
+import datetime
from packer import Packer
-from datatypes import serial, RangedSet, Struct
+from datatypes import serial, timestamp, RangedSet, Struct
class CodecException(Exception): pass
@@ -103,9 +104,11 @@ class Codec(Packer):
self.pack("!q", n)
def read_datetime(self):
- return self.read_uint64()
- def write_datetime(self, n):
- self.write_uint64(n)
+ return timestamp(self.read_uint64())
+ def write_datetime(self, t):
+ if isinstance(t, datetime.datetime):
+ t = timestamp(t)
+ self.write_uint64(t)
def read_double(self):
return self.unpack("!d")