JSTZ is a JavaScript library designed for client-side timezone detection within a user's browser, returning an IANA zone info key (e.g., 'America/Los_Angeles'). It is currently at version 2.1.1. As an unofficial fork of the original `pellepim/jstimezonedetect` project, its primary differentiator is enabling installation and usage via NPM for module-based environments (like Webpack or Browserify), as the original focused on CDN distribution. While there isn't a strict, frequent release cadence, updates have addressed specific bugs and improved TypeScript definitions. It's often used in conjunction with server-side frameworks or other date-time parsing libraries like Moment Timezone to determine the user's local timezone without requiring user input.
npm install jstzVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to import jstz, detect the user's timezone, and display its IANA name. It includes error handling and notes for both browser and Node-like environments.
Always refer to the official GitHub repository (iansinnott/jstz) for this specific NPM package's documentation and issue tracker. If using via CDN, use the original library.
Upgrade to `jstz@2.0.0` or newer to incorporate the Firefox bug fix: `npm install jstz@latest`.
Implement explicit mapping logic between IANA timezones and `ActiveSupport::TimeZone` names. For `Intl` conflicts, consider the provided Rails example in the `jstz` README to temporarily undefine `window.Intl` before calling `jstz.determine()` if needed.
Always import `jstz` as a default export and access `determine()` as a method on the imported object: `import jstz from 'jstz'; jstz.determine();`
For ESM: `import jstz from 'jstz';`. For CJS: `const jstz = require('jstz');`. Ensure script tags are loaded correctly in HTML for global usage (though module systems are recommended for this package).Verify that `jstz` is imported as a default export (`import jstz from 'jstz';` or `const jstz = require('jstz');`) and that `determine()` is called on the imported object.Ensure `const timezone = jstz.determine();` is correctly executed and that `name()` is called as a method: `timezone.name()`. Inspect the `timezone` object to confirm its structure if the error persists.
Implement explicit mapping logic on the server-side to translate `jstz`'s IANA names to `ActiveSupport::TimeZone` names. The `jstz` README provides an example `browser_time_zone` helper method for Rails that attempts this translation and provides a fallback.
No dependency data recorded yet.