From 8be83d96ee667728d8a5da0db2e68e29c2177dda Mon Sep 17 00:00:00 2001 From: "Rafael H. Schloming" Date: Mon, 10 Nov 2008 15:19:29 +0000 Subject: 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 --- python/qpid/codec010.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'python/qpid/codec010.py') 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") -- cgit v1.2.1