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

April 2016 isSame as empty object #3085

Closed
dzx11 opened this issue Apr 1, 2016 · 7 comments
Closed

April 2016 isSame as empty object #3085

dzx11 opened this issue Apr 1, 2016 · 7 comments

Comments

@dzx11
Copy link

dzx11 commented Apr 1, 2016

https://jsfiddle.net/u71dx24a/1/

When comparing dates, if you compare Apr 2016 to an empty moment object, the isSame method returns true. This is not the case with March 2016, or April 2015.

@icambron
Copy link
Member

icambron commented Apr 1, 2016

It's actually just that moment({}) is returning the beginning of today, which is the same date as the beginning of April.

moment("april 2016").format()
"2016-04-01T00:00:00-04:00"
moment({}).format()
"2016-04-01T00:00:00-04:00"

It's fair to ask why moment({}) returns today's date instead of the current MS; I think that's a bit unexpected as far as undefined behaviors go.

@Changron
Copy link

Should we modifiy it to make the default value become current MS?

@ottoliar
Copy link

I'd like to take a closer look at this if possible. I think it's reasonable to expect calling moment({}) or moment([]) would result in the same as just calling moment()

@icambron
Copy link
Member

I agree. Would accept a PR.

@jakeaaron
Copy link

Hello,

I would like to take a crack at this for my first contribution!
What source should I be looking at?
So should moment check if an empty object is passed and return the same value as if no parameter was passed?

Thanks!

@maggiepint
Copy link
Member

@jakeaaron there is actually already an open PR on this, #3111. We have a few more up-for-grabs that we would love for you to take a look at.

My bad for not closing this earlier, doing so now.

@jakeaaron
Copy link

Ok, no problem!
Thanks!

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

Successfully merging a pull request may close this issue.

6 participants