getLocalTimeZone cache #7195
Unanswered
stuartkeith
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Looks like there is a proposal for a Not sure of a good solution for now, but maybe doing something with the Page Visibility API at the application level. I think that's too opinionated to be included by default though. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I noticed getLocalTimeZone internally caches the result, so it's only calculated once:
react-spectrum/packages/@internationalized/date/src/queries.ts
Lines 118 to 128 in 987f174
This was added in #2264, with a TODO about invalidating it somehow in the future (which has not been done, as far as I can see).
This can cause unexpected behaviour if the user happens to change timezone (e.g. they close their laptop in one timezone, go somewhere, open it in another timezone).
Does anyone have any insight as to why this was done, or whether it's a known issue? I can see #2264 mentions improving date formatting performance, so I can imagine caching is part of that, although I wonder how much the timezone calculation was contributing to the formatting as opposed to everything else.
Beta Was this translation helpful? Give feedback.
All reactions