Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property zoneName of undefined #56

Open
jaynakus opened this issue Aug 11, 2017 · 7 comments
Open

Cannot read property zoneName of undefined #56

jaynakus opened this issue Aug 11, 2017 · 7 comments

Comments

@jaynakus
Copy link

On some windows 10 computers with non english language this error is thrown in Timezone/index.js. I think timezone guessing utility cannot detect it.

@ecmadao
Copy link
Owner

ecmadao commented Aug 12, 2017

@jaynakus
Thanks for your feedback! I'll check it later.

@jirikolarik
Copy link

jirikolarik commented Oct 2, 2017

Doesn't work on Chrome either in Europe.

moment.tz.guess() is using Intl.DateTimeFormat().resolvedOptions().timeZone which returns CET and getTzForName("CET") returns undefined

@gnilk
Copy link

gnilk commented Oct 4, 2017

I added this in my local branch to getTzForName. Does solve the problem but I have no clue if it's a fix. Basically searching the abbreviation as well as the zone name if the first fail.

  if (maps.length == 0) {
    maps = tzMaps.filter(function(tzMap) {
      return tzMap['zoneAbbr'] === name;
    })
  }

full function now looks like:

var getTzForName = function getTzForName(name) {
  var maps = tzMaps.filter(function (tzMap) {
    return tzMap['zoneName'] === name;
  });
  if (maps.length == 0) {
    maps = tzMaps.filter(function(tzMap) {
      return tzMap['zoneAbbr'] === name;
    })
  }
  return (0, _func.head)(maps);
};

@ecmadao
Copy link
Owner

ecmadao commented Oct 4, 2017

Sorry guys, I'm taking a vacation these days and just see your comments. First of all, many thanks for your feedback! But it really works well for me, so I have to do more debug to check, and maybe use @gnilk 's solution to publish a small bugfix version to check if it help.

@ecmadao
Copy link
Owner

ecmadao commented Oct 4, 2017

Publish a new version V2.2.2, using your @gnilk solution, thanks. Your can update and check if it works.

@gnilk
Copy link

gnilk commented Oct 4, 2017

Seems to work. Thanks!

@JensC
Copy link

JensC commented Oct 23, 2023

I am using a version 2.2.10 and I still have the problem mentioned above. Does the version 2.2.10 support predefined property "timezone" and would that inhibit the error? Unfortunately I do not have a Windows 10 at hand and I am stuck using this older version of react-times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants