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

Add optional time argument to calendar method #1554

Merged

Conversation

jgillman
Copy link
Contributor

For example:

moment().calendar()
// => Today at [...]

fakeToday = moment().subtract( 'days', 1 )
moment().calendar( fakeToday )
// "Today" from the perspective of yesterday (`fakeToday`) is "tomorrow".
// => Tomorrow at [...]

I'm not sure how useful this would be outside of a testing environment, but with it you can test the calendar method by feed it a stubbed out "now".

Mostly useful for running tests when you need to stub out time as a
specific time. Or for if you want to get "calendar" style formating
relative to a time that is not "now".
@jgillman
Copy link
Contributor Author

Recreated pull request from #1553 minus the grunt release commit.

@ichernev
Copy link
Contributor

ichernev commented Apr 2, 2014

I think the change makes sense. Can you please add some more tests though :)

ichernev added a commit that referenced this pull request May 21, 2014
…argument

Add optional time argument to calendar method
@ichernev ichernev merged commit fbd97ea into moment:develop May 21, 2014
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.

2 participants