question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

utils.strftime does not format the year properly

See original GitHub issue

4Y is set as the date

>>> now = pytz.utc.localize(datetime.utcnow())
>>> now
datetime.datetime(2017, 12, 2, 19, 58, 13, 276787, tzinfo=<UTC>)
>>> utils.strftime(now)
'4Y-12-02T19:58:13.276787Z'

Looks like this was introduced by https://github.com/singer-io/singer-python/pull/52

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
nick-mccoycommented, Mar 12, 2018

Hi @bondgeek, I think we are going to change singer-python’s strftime() to do something similar to what was done in this pull request.

I will link the change here once it happens to keep anyone following this thread in the loop.

0reactions
dipamacharyyacommented, Oct 10, 2022

I’m running tap-onfleet --config config.json --catalog catalog.json but getting an unknown string format for my system time

INFO administrators: Starting sync INFO GET request to https://onfleet.com/api/v2/admins INFO METRIC: {“type”: “counter”, “metric”: “record_count”, “value”: 0, “tags”: {“endpoint”: “administrators”}} CRITICAL Unknown string format: 2022-10-10 11:13:18 Pacific Daylight Time Traceback (most recent call last): File “C:\python39\lib\runpy.py”, line 197, in run_module_as_main return run_code(code, main_globals, None, File “C:\python39\lib\runpy.py”, line 87, in run_code exec(code, run_globals) File "C:\Python39\Scripts\tap-onfleet.exe_main.py", line 7, in <module> File “C:\python39\lib\site-packages\singer\utils.py”, line 192, in wrapped return fnc(*args, **kwargs) File "C:\python39\lib\site-packages\tap_onfleet_init.py", line 91, in main sync(client, parsed_args.catalog, state) File "C:\python39\lib\site-packages\tap_onfleet_init.py", line 66, in sync counter_value = sync_stream(state, instance) File “C:\python39\lib\site-packages\tap_onfleet\sync.py”, line 19, in sync_stream for (stream, record) in instance.sync(state): File “C:\python39\lib\site-packages\tap_onfleet\streams.py”, line 103, in sync self.update_bookmark(state, item[self.replication_key]) File “C:\python39\lib\site-packages\tap_onfleet\streams.py”, line 55, in update_bookmark if self.is_bookmark_old(state, value): File “C:\python39\lib\site-packages\tap_onfleet\streams.py”, line 61, in is_bookmark_old return utils.strptime_with_tz(value) > utils.strptime_with_tz(current_bookmark) File “C:\python39\lib\site-packages\singer\utils.py”, line 21, in strptime_with_tz d_object = dateutil.parser.parse(dtime) File “C:\python39\lib\site-packages\dateutil\parser_parser.py”, line 1368, in parse return DEFAULTPARSER.parse(timestr, **kwargs) File “C:\python39\lib\site-packages\dateutil\parser_parser.py”, line 643, in parse raise ParserError(“Unknown string format: %s”, timestr) dateutil.parser._parser.ParserError: Unknown string format: 2022-10-10 11:13:18 Pacific Daylight Time

Can someone please help?

Read more comments on GitHub >

github_iconTop Results From Across the Web

(django) strftime format does not work properly, different ...
You need to set a timezone-aware datetime as the pub_date when you create a new ArticleComments instance. from django.utils import timezone ...
Read more >
datetime — Basic date and time types — Python 3.11.1 ...
Return a string representing the date, controlled by an explicit format string. Format codes referring to hours, minutes or seconds will see 0...
Read more >
Python Examples of singer.utils.strftime - ProgramCreek.com
The following are 18 code examples of singer.utils.strftime(). ... val.year == 0: # NB: Since datetimes are persisted as strings, it doesn't #...
Read more >
strptime: Date-time Conversion Functions to and from Character
Any character in the format string not part of a conversion specification is ... will probably not print years before 1 CE (aka...
Read more >
12261 (strftime function from django.utils.datetime_safe doesn ...
However the function strftime doesn't handle properly the option "%Y" in years below 1000: instead to fill with zeros (0) until to complete...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found