date-fns-timezone
date-fns-timezone copied to clipboard
Support for limited 2012-2022 timezone data
Nice library! date-fns really needs this timezone support built into the library.
Is there any support for only including the 2012-2022 timezone-support data?
Currently it looks like imports are coming from the timezone-support index which includes all of the data by default.
Yes, I'm afraid that you're right. You cannot decide, what time zone data will be used on the date-fns-timezone level.
Actually, I didn't expect, that the 2012-2022 data would be wanted so much :-) I didn't consider it important, because dates are entered in form fields im my application and it is impossible to predict how old date will be entered there. Hence always all time zones...
timezone-support is a bunch of functions and no object instance to initialize and send around. I will need to think something up, either some context object with the time zone data, or a global initialization.
Very nice library, thanks! But yes, we have a similar problem: we need to use a custom timezone data bundle generated by timezone-support. Any suggestions on how to add this? I'd be happy to put in a PR.
Any updates?
If using webpack you can alias timezone-support to one of the limited data versions.
resolve: {
alias: {
'timezone-support$': path.resolve(
__dirname,
'node_modules/timezone-support/dist/index-1970-2038.js'
)
}
}
with gatsby in gatsby-node.js:
const path = require('path');
exports.onCreateWebpackConfig = ({ actions }) => {
actions.setWebpackConfig({
resolve: {
alias: {
'timezone-support$': path.resolve(
__dirname,
'node_modules/timezone-support/dist/index-2012-2022.js'
),
},
},
});
};