You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would it make sense to consider adding the timezone to the setDefaultOptions?
Having a global internal setting, that can be used in both formatting and the other date-fns operations, would be quite useful.
Example
An example would be the good old moment.js. They have the setDefault option for timezones.
Context
We're trying to migrate a project from moment.js to date-fns, and in our project, we have a feature for admins to impersonate a user's timezone. This helps people see what the user is exactly seeing, from the statistics or dashboard to the formatting of the dates. Since moment.js keeps this setting internally and shares it between the different instances, we can simply use moment.tz.setDefault(userTimezone) and that would do the trick.
Questions
Does this proposal make any sense?
If yes, how do you see a possible pathway forward, especially with the existence of date-fns-tz?
Closing thoughts
Of course, we can try wrapping our project with a singleton or some functions and try and use that everywhere, but I'm not sure how doable or if that would be the best approach moving forward.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Idea
Would it make sense to consider adding the timezone to the
setDefaultOptions
?Having a global internal setting, that can be used in both formatting and the other date-fns operations, would be quite useful.
Example
An example would be the good old moment.js. They have the setDefault option for timezones.
Context
We're trying to migrate a project from moment.js to date-fns, and in our project, we have a feature for admins to impersonate a user's timezone. This helps people see what the user is exactly seeing, from the statistics or dashboard to the formatting of the dates. Since moment.js keeps this setting internally and shares it between the different instances, we can simply use
moment.tz.setDefault(userTimezone)
and that would do the trick.Questions
date-fns-tz
?Closing thoughts
Of course, we can try wrapping our project with a singleton or some functions and try and use that everywhere, but I'm not sure how doable or if that would be the best approach moving forward.
Beta Was this translation helpful? Give feedback.
All reactions