From be8b565273d08c14716ff9e3956f7fb02b5e370f Mon Sep 17 00:00:00 2001 From: Nick McCoy Date: Thu, 14 Dec 2017 11:10:15 -0500 Subject: [PATCH 1/2] changing strftime format string --- singer/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/singer/utils.py b/singer/utils.py index 5315484..048c138 100644 --- a/singer/utils.py +++ b/singer/utils.py @@ -11,7 +11,7 @@ from singer.catalog import Catalog DATETIME_PARSE = "%Y-%m-%dT%H:%M:%SZ" -DATETIME_FMT = "%04Y-%m-%dT%H:%M:%S.%fZ" +DATETIME_FMT = "%Y-%m-%dT%H:%M:%S.%fZ" def now(): return datetime.datetime.utcnow().replace(tzinfo=pytz.UTC) @@ -29,10 +29,10 @@ def strptime(dtime): except Exception: return datetime.datetime.strptime(dtime, DATETIME_PARSE) -def strftime(dtime): +def strftime(dtime, format_str=DATETIME_FMT): if dtime.utcoffset() != datetime.timedelta(0): raise Exception("datetime must be pegged at UTC tzoneinfo") - return dtime.strftime(DATETIME_FMT) + return dtime.strftime(format_str) def ratelimit(limit, every): def limitdecorator(func): From 215171b445771623053ea649d8192e4bf4ad4a24 Mon Sep 17 00:00:00 2001 From: Nick McCoy Date: Thu, 14 Dec 2017 15:42:41 -0500 Subject: [PATCH 2/2] fixing strftime format string --- tests/test_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_utils.py b/tests/test_utils.py index cd7fc42..0b89448 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -6,5 +6,5 @@ class TestFormat(unittest.TestCase): def test_small_years(self): - self.assertEqual(u.strftime(dt(90, 1, 1, tzinfo=tz.utc)), + self.assertEqual(u.strftime(dt(90, 1, 1, tzinfo=tz.utc), '%04Y-%m-%dT%H:%M:%S.%fZ'), "0090-01-01T00:00:00.000000Z")