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.

from_format('12/2/2015 12:00:00 AM EST', 'M/D/YYYY h:mm:ss A zz')

See original GitHub issue
>>> pendulum.from_format('12/2/2015 12:00:00 AM EST', 'M/D/YYYY h:mm:ss A zz')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/nackjicholson/Library/Caches/pypoetry/virtualenvs/source-data-service-py3.6/lib/python3.6/site-packages/pendulum/__init__.py", line 256, in from_format
    parts = _formatter.parse(string, fmt, now(), locale=locale)
  File "/Users/nackjicholson/Library/Caches/pypoetry/virtualenvs/source-data-service-py3.6/lib/python3.6/site-packages/pendulum/formatting/formatter.py", line 400, in parse
    lambda m: self._replace_tokens(m.group(0), locale), escaped_fmt
  File "/Users/nackjicholson/Library/Caches/pypoetry/virtualenvs/source-data-service-py3.6/lib/python3.6/site-packages/pendulum/formatting/formatter.py", line 400, in <lambda>
    lambda m: self._replace_tokens(m.group(0), locale), escaped_fmt
  File "/Users/nackjicholson/Library/Caches/pypoetry/virtualenvs/source-data-service-py3.6/lib/python3.6/site-packages/pendulum/formatting/formatter.py", line 651, in _replace_tokens
    raise ValueError("Unsupported token: {}".format(token))
ValueError: Unsupported token: zz

This is from the master branch. The zz is in the documentation, I feel like it should work.

The from_format functionality is very important to my usage of pendulum. I’d like to find some time to dig in and see if I can help make it better but I could use some guidance. Do you have any idea why it has been unreliable? Is there some other approach that you might want to take in order to improve it?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:9
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
altendkycommented, May 14, 2019

Some abbreviations are present in the regular pendulum.timezones list (in other words, z).

>>> tuple(tz for tz in pendulum.timezones if '/' not in tz and tz[:2].isupper())
('CET', 'CST6CDT', 'EET', 'EST', 'EST5EDT', 'GB', 'GB-Eire', 'GMT', 'GMT+0', 'GMT-0', 'GMT0', 'HST', 'MET', 'MST', 'MST7MDT', 'NZ', 'NZ-CHAT', 'PRC', 'PST8PDT', 'ROC', 'ROK', 'UCT', 'UTC', 'W-SU', 'WET')

But that list seems lacking enough for the US, let alone with a less US-centric view, to be not particularly useful.

I’m not sure there’s a general solution to this as I don’t believe the abbreviations are well defined enough to be unique. Still, they certainly are used and the ambiguity could be overcome by allowing the caller to pass a mapping of unique abbreviations to unique names. {'CDT': 'America/Chicago'} (hopefully that’s a good example but…) Optionally, regional default lists could be provided for easy use.

0reactions
altendkycommented, Oct 12, 2021

I agree that it is accurate for this issue to be in the open state. I don’t have authority to make the fix happen and I have lots of other open source work I am more responsible for that needs my time. Sorry. :[

(nitpick, this issue is three years old, not two)

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

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