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
base: develop
from

Conversation

Projects
None yet
4 participants
@generalov
Contributor

generalov commented Apr 26, 2016

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

Call calendar format function with moment context
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

This comment has been minimized.

Contributor

ichernev commented Apr 30, 2016

That seems reasonable. Will merge in next release.

@ichernev

This comment has been minimized.

Contributor

ichernev commented Jun 14, 2016

Merged in 8fa1934

@ichernev ichernev closed this Jun 14, 2016

ichernev added a commit that referenced this pull request Jun 14, 2016

Merge pull request #3147 from generalov:patch-1
Call calendar format function with moment context

@mj1856 mj1856 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