Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

date_format doesn't respect localized time zone #8

Closed
lorin opened this issue Dec 2, 2017 · 3 comments
Closed

date_format doesn't respect localized time zone #8

lorin opened this issue Dec 2, 2017 · 3 comments
Labels

Comments

@lorin
Copy link

lorin commented Dec 2, 2017

date_format doesn't respect the time zone of a pandas.Timestamp:

>>> from mizani.formatters import date_format
>>> import pandas as pd
>>>
>>> ts_utc = pd.Timestamp('2017-11-30 23:16:00', tz='UTC')
>>> ts_pst = ts_utc.tz_convert('US/Pacific')
>>> ts_pst.strftime("%H")
'15'
>>> date_format("%H")([tc_pst])
['23']
@has2k1 has2k1 added the bug label Dec 2, 2017
@has2k1
Copy link
Owner

has2k1 commented Dec 2, 2017

Work around

>>> f = date_format("%H")
>>> f.formatter.tz = ts_pst.tz
>>> f([ts_pst])
['15']

@has2k1
Copy link
Owner

has2k1 commented Dec 2, 2017

The issue is, because we use Matplotlib internals the most sane solution would be to use the timezone of the first date. So if you pass the format functions times with different dates the result may be surprising.

@lorin
Copy link
Author

lorin commented Dec 2, 2017

Seems reasonable, and it would cover my use case.

If you were concerned about a user submitting different timezones, you could do a check that they are all the same and emit a warning if they aren't.

has2k1 added a commit that referenced this issue Dec 6, 2017
The MPL DateFormatter knows how to handle time zones.
It does not infer time zones from the data. We have
to explicitly set the time zone information.

fixes #8
has2k1 added a commit that referenced this issue Dec 6, 2017
The MPL DateFormatter knows how to handle time zones.
It does not infer time zones from the data. We have
to explicitly set the time zone information.

fixes #8
@has2k1 has2k1 closed this as completed in b59dea8 Dec 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants