Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions singer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")