Merge "Remove iso8601_from_timestamp"

This commit is contained in:
Jenkins 2017-09-27 00:26:42 +00:00 committed by Gerrit Code Review
commit d975485a15
3 changed files with 10 additions and 5 deletions

View File

@ -133,11 +133,12 @@ def stat_message(message, now):
msg_id = message['id'] msg_id = message['id']
created = oid_ts(to_oid(msg_id)) created = oid_ts(to_oid(msg_id))
age = now - created age = now - created
created_iso = datetime.datetime.utcfromtimestamp(created).strftime(
'%Y-%m-%dT%H:%M:%SZ')
return { return {
'id': msg_id, 'id': msg_id,
'age': int(age), 'age': int(age),
'created': timeutils.iso8601_from_timestamp(created), 'created': created_iso,
} }

View File

@ -14,12 +14,12 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import datetime
import functools import functools
import uuid import uuid
import msgpack import msgpack
from oslo_utils import encodeutils from oslo_utils import encodeutils
from oslo_utils import timeutils
from oslo_utils import uuidutils from oslo_utils import uuidutils
MSGENV_FIELD_KEYS = (b'id', b't', b'cr', b'e', b'u', b'c', b'c.e', b'c.c') MSGENV_FIELD_KEYS = (b'id', b't', b'cr', b'e', b'u', b'c', b'c.e', b'c.c')
@ -232,7 +232,8 @@ class Message(MessageEnvelope):
} }
if include_created: if include_created:
created_iso = timeutils.iso8601_from_timestamp(self.created) created_iso = datetime.datetime.utcfromtimestamp(
self.created).strftime('%Y-%m-%dT%H:%M:%SZ')
basic_msg['created'] = created_iso basic_msg['created'] = created_iso
return basic_msg return basic_msg

View File

@ -12,6 +12,7 @@
# limitations under the License. # limitations under the License.
import copy import copy
import datetime
import functools import functools
import uuid import uuid
@ -341,10 +342,12 @@ class MessageQueueHandler(object):
raise raise
else: else:
created = float(headers['x-timestamp']) created = float(headers['x-timestamp'])
created_iso = datetime.datetime.utcfromtimestamp(
created).strftime('%Y-%m-%dT%H:%M:%SZ')
newest = { newest = {
'id': obj['name'], 'id': obj['name'],
'age': now - created, 'age': now - created,
'created': timeutils.iso8601_from_timestamp(created)} 'created': created_iso}
if oldest is None: if oldest is None:
oldest = copy.deepcopy(newest) oldest = copy.deepcopy(newest)
total += 1 total += 1