Contructor issue with non-None timezone
See original GitHub issueConstructor of Arrow object (arrow.py) fails if tzinfo is non-None and if it does not contain field “zone”.
The problematic part:
isinstance(tzinfo, dt_tzinfo)
and hasattr(tzinfo, "localize")
and tzinfo.zone
):
should be like
isinstance(tzinfo, dt_tzinfo)
and hasattr(tzinfo, "localize")
and hasattr(tzinfo, "zone")
):
The change came since version 0.14.5
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Weird timezone issue with pytz - python - Stack Overflow
When you use localize to attach the zone to a date, the proper zone name and offset are substituted. Simply using the datetime...
Read more >pd.Timestamp constructor ignores missing arguments #31930
The constructor argument-handling behavior is a problem. I, however, disagree that constructing timezone-aware Timestamps should happen in two ...
Read more >TimeZone (Java Platform SE 7 ) - Oracle Help Center
Returns the amount of time in milliseconds to add to UTC to get standard time in this time zone. Because this value is...
Read more >datetime — Basic date and time types — Python 3.11.1 ...
Date and time objects may be categorized as “aware” or “naive” depending on whether or not they include timezone information.
Read more >Working with dates and timezones in JavaScript - Ursa Health
Nor are date and timezone problems the sort of issue that a great library can ... The timezone that Dave Jorgenson happened to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi guys, hope that you are well. Say, I have a (simple) program like:
Results: with arrow 0.15.0 (since 0.14.5) The first date passes however the the second fails. with arrow 0.14.4 (I tested on 0.13.1) Both pass
Explanation of the failure: parsed_date is of type datetime with component variable tzinfo of type StaticTzInfo. The StaticTzInfo type has two component variables _StaticTzInfo__name of type str and _StaticTzInfo__offset of type timedelta. When such variable is inserted into arrow through get it fails in the constructor of arrow class because tzinfo in the constructor is of type StaticTzInfo that does not have component variable zone and that is why the interpreter says AttributeError: ‘StaticTzInfo’ object has no attribute ‘zone’
My comment: I do not know if the test of zone component is correct. If yes that it should test presence of the variable and then the value if that is needed.
Regression for this case would be really needed. Well, it could test more that one timezone and take into account some special ones with non-integer shifts.
Bye, Hynek
Thanks @mafycek, we will do some digging on this bug and look at fixes.
Useful note, you can wrap python code blocks like this.
```python INSERT BUG HERE ```