From 3b4f17bc18c34ae4c7ec37e9d4dff41a32abdc28 Mon Sep 17 00:00:00 2001 From: Nikita Konovalov Date: Fri, 3 Apr 2015 14:53:35 +0300 Subject: [PATCH] Date format set to be correct utc date As it turned out the format of the date used in Sahara may not be understood by som JavaScript engines which prevents the dates to be displayed correctly in UI. The milliseconds part of the time is also removed as it has never been necessary to access the dates with that accuracy. However the presence or sometime absence of the .ms suffix makes it harder to handle dates. Closes-Bug: #1443343 Change-Id: I1f4cc6dc443605ba632c1458bba8bd47a0e1a01f --- sahara/db/sqlalchemy/model_base.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sahara/db/sqlalchemy/model_base.py b/sahara/db/sqlalchemy/model_base.py index 08e660cd..421dc102 100644 --- a/sahara/db/sqlalchemy/model_base.py +++ b/sahara/db/sqlalchemy/model_base.py @@ -42,6 +42,11 @@ class _SaharaBase(oslo_models.ModelBase, oslo_models.TimestampMixin): def datetime_to_str(dct, attr_name): if dct.get(attr_name) is not None: - dct[attr_name] = dct[attr_name].isoformat(' ') + value = dct[attr_name].isoformat('T') + ms_delimiter = value.find(".") + if ms_delimiter != -1: + # Removing ms from time + value = value[:ms_delimiter] + dct[attr_name] = value SaharaBase = declarative.declarative_base(cls=_SaharaBase)