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
merged 1 commit into from May 21, 2014

Conversation

Projects
None yet
2 participants
@jgillman
Contributor

jgillman commented Mar 27, 2014

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".

Add optional time argument to calendar method
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

This comment has been minimized.

Contributor

jgillman commented Mar 27, 2014

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

@ichernev

This comment has been minimized.

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

Merge pull request #1554 from Goldbely/feature/calendar-accepts-time-…
…argument

Add optional time argument to calendar method

@ichernev ichernev merged commit fbd97ea into moment:develop May 21, 2014

1 check passed

default The Travis CI build passed
Details

@theurere theurere referenced this pull request Jul 1, 2014

Merged

Update moment.js to 2.7.0 #58

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment