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

TypeError: Cannot read property 'humanize' of undefined #116

Open
Nantris opened this issue Dec 13, 2019 · 1 comment
Open

TypeError: Cannot read property 'humanize' of undefined #116

Nantris opened this issue Dec 13, 2019 · 1 comment

Comments

@Nantris
Copy link

Nantris commented Dec 13, 2019

It seems really weird, because simpleFormat works fine, but humanizeLength invariably fails with the error TypeError: Cannot read property 'humanize' of undefined

const getText = timeToAdd => {
  const now = moment();
  const reminderTime = moment().add(timeToAdd, 'minutes');
  const range = now.twix(reminderTime.format()); //  range is a time span from the current time to the reminderTime
   const humanized = range.humanizeLength();  //  Fails with "TypeError: Cannot read property 'humanize' of undefined"
  // const humanized = range.simpleFormat();  //  Works fine
  return humanized;
};

Any thoughts? Thanks for this great project!

@icambron
Copy link
Owner

It seems like that error would be somewhere in Moment. Twix is essentially doing this:

var startMoment = range.start();
var endMoment = range.end();
startMoment.from(endMoment);

And somehow, I'm guessing, inside of Moment's from, there's an error calling humanize internally. I can't imagine why that would happen, though.

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

2 participants