Format DateAxisItem ticks in different timezones correctly#3083
Format DateAxisItem ticks in different timezones correctly#3083j9ac9k merged 6 commits intopyqtgraph:masterfrom
Conversation
| return -roundedToHour.secsTo(local.time()) | ||
|
|
||
|
|
||
| def shiftLocalTimeToUtcTime(timestamp): |
There was a problem hiding this comment.
i still have no idea how to properly name this function
There was a problem hiding this comment.
inverseUTCOffset? That's my first thought
There was a problem hiding this comment.
Going from UTC to the user timezones is sometimes called "localize". That would make this "delocalize", maybe?
There was a problem hiding this comment.
I'm good w/ delocalize, but with all naming conventions, I try and conform to what Qt does upstream.
We could expand on Qt's API which has offsetFromUtc
And do:
def applyOffsetFromUtc:
...
def applyOffsetToUtc:
...There was a problem hiding this comment.
That seems like a good precedent!
|
|
||
|
|
||
| def calculateUtcOffset(timestamp): | ||
| return -fromSecsSinceEpoch(timestamp).offsetFromUtc() |
There was a problem hiding this comment.
negative, because previous implementation returned time.timezone or time.altzone, which are negative if the local DST timezone is east of UTC, and Qt returns negatives for west
hopefully make them work on different platforms correctly without being affected by bugs in dependencies
and shiftedOffsetFromUtc to applyOffsetToUtc (as was proposed in pyqtgraph#3083 (comment))
...when only its spacing is needed
|
Hi @Gatsik Thanks so much for this PR, the DateAxisItem has been something elusive to me, and I always felt we should use Qt's timezone support rather than Python's... Right now CI seems to be freaking out about unexpected locale settings (note this isn't a pytest.fail but an error being raised). Weird, the locale error is only on Linux runs... Per this SO post, maybe we need to set the environment variable to support different locales? https://stackoverflow.com/a/37112094/5298841 Probably need to add that setting here? https://github.com/pyqtgraph/pyqtgraph/blob/master/.github/workflows/main.yml#L10 |
i am not sure, maybe we don't need to check day ticks at all? since the most important part is hours in the test function |
i checked, and looks like |
fix its tests: use C locale, which seems to be available on Windows, Linux and MacOS
An attempt to resolve #1389
I tried to follow the recommendations from this comment, which suggested touching less code, but somewhat failed, because my IDE trims whitespaces on save automatically (i hope, this is not a big deal)