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

Call calendar format function with moment context #3147

Closed
wants to merge 1 commit into from

Conversation

generalov
Copy link
Contributor

What: the code:

moment().days(-1000).calendar(null, {
   sameElse: function() {
       return '[hoy a la'   ((this.hours() !== 1) ? 's' : '')   '] LT';
   }
});

Where: on http://momentjs.com/docs/#/displaying/calendar-time/ in the Chrome console.
What I got: It raises Uncaught TypeError: this.hours is not a function

I expected use callback like in the example on http://momentjs.com/docs/#/customization/calendar/ .

This PR makes the compatible call with https://github.com/moment/moment/blob/develop/src/lib/locale/calendar.js#L14

What: the code:
```
moment().days(-1000).calendar(null, {
   sameElse: function() {
       return '[hoy a la'   ((this.hours() !== 1) ? 's' : '')   '] LT';
   }
});
```
Where: on http://momentjs.com/docs/#/displaying/calendar-time/ in the Chrome console.
What I got: It raises `Uncaught TypeError: this.hours is not a function`

I expected use callback like in the example on http://momentjs.com/docs/#/customization/calendar/ .

This PR makes the compatible call with https://github.com/moment/moment/blob/develop/src/lib/locale/calendar.js#L14
@ichernev
Copy link
Contributor

That seems reasonable. Will merge in next release.

@ichernev
Copy link
Contributor

Merged in 8fa1934

@ichernev ichernev closed this Jun 14, 2016
ichernev added a commit that referenced this pull request Jun 14, 2016
Call calendar format function with moment context
@mattjohnsonpint mattjohnsonpint added this to the 2.14.0 milestone Jul 5, 2016
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

Successfully merging this pull request may close these issues.

4 participants