0

I am trying to replace bower in my repo and I am having trouble replacing this package: "jsTimezoneDetect": "1.0.4". The suggested package to replace this is "jstimezonedetect": "^1.0.6". I am using this package as shown here:

var missionJoin = {
    timeZoneId : jstz.determine().name()
};

This however, gives me this error:

ReferenceError: Can't find variable: Intl in node_modules/jstimezonedetect/dist/jstz.js (line 124)
get_from_internationalization_api@node_modules/jstimezonedetect/dist/jstz.js:124:22
determine@node_modules/jstimezonedetect/dist/jstz.js:412:67
joinMission@app/scripts/controllers/robo.profile.ProfileServiceCtrl.js:1:27975
test/specs/robo.profile.profileServiceCtrl.spec.js:151:27
<Jasmine>

This package does not have any dependencies and the error seems to come from a problem in the package itself. Is there something I am doing wrong here? Has anyone else faced a similar issue? Any help would be greatly appreciated!

1 Answers1

0

For anyone who might face this problem in the future, here is how I got around this issue:

Found in the last paragraph of https://github.com/iansinnott/jstz

export function findTimeZone() {
  const oldIntl = window.Intl
  try {
    window.Intl = undefined
    const tz = jstz.determine().name()
    window.Intl = oldIntl
    return tz
  } catch (e) {
    // sometimes (on android) you can't override intl
    return jstz.determine().name()
  }
}

and

var missionJoin = {
    timeZoneId : findTimeZone()
};