From d3a4c8e8f466d5c7b2f5f8c076a48326e5bbaa40 Mon Sep 17 00:00:00 2001 From: Flaper Fesp Date: Mon, 21 Jan 2013 16:31:51 +0100 Subject: UTC ISO8601 from timestamp Taken from glance xattr.py module. This function converts timestamp formated dates into a UTC Iso 8601 date. It is being required in multiple places now (mostly on clients printing dates) in order to make dates human readable. Change-Id: I6f19325a4c2df241a0ef76bd256280a2930d9265 --- tests/unit/test_timeutils.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/unit/test_timeutils.py') diff --git a/tests/unit/test_timeutils.py b/tests/unit/test_timeutils.py index 1407f29..04ddd4d 100644 --- a/tests/unit/test_timeutils.py +++ b/tests/unit/test_timeutils.py @@ -15,6 +15,7 @@ # License for the specific language governing permissions and limitations # under the License. +import calendar import datetime import unittest @@ -148,6 +149,12 @@ class TimeUtilsTest(unittest.TestCase): self.assertAlmostEquals(604859.123456, timeutils.delta_seconds(before, after)) + def test_iso8601_from_timestamp(self): + utcnow = timeutils.utcnow() + iso = timeutils.isotime(utcnow) + ts = calendar.timegm(utcnow.timetuple()) + self.assertEqual(iso, timeutils.iso8601_from_timestamp(ts)) + class TestIso8601Time(unittest.TestCase): -- cgit