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

Why is month value a 0 based array? #12

Closed
Shakebag opened this issue Jan 3, 2019 · 2 comments
Closed

Why is month value a 0 based array? #12

Shakebag opened this issue Jan 3, 2019 · 2 comments

Comments

@Shakebag
Copy link

Shakebag commented Jan 3, 2019

What is the point of having a 0 based index for the month field? Shouldn't it be the month number that it corresponds with?

<MonthPicker classes={'datePicker'} {...rest} defaultValue={'Month'} // default is 1900 start={1} // default is ASCENDING reverse // default is false value={value} // mandatory onChange={month => onChange(month)} required={true} />

For some reason in the react developer tools I see:
<option key='0' value{0} className={null}>1</option>
Then rendered in html :
<option value="0">1</option>

@ssxv
Copy link
Owner

ssxv commented Jan 4, 2019

Sure it could have been 1-12..
But I kept it 0-11 to keep in line with JavaScript's months which are 0-11.

@Shakebag
Copy link
Author

That's a valid reason. I poked around online and found some interesting comments about it likely coming from C function implementation(Link to stack overflow discussion). That's why I was confused. Traditionally I've posted to my server side complete dates, but for some reason another developer used your library and posted the values from the components individually throwing everything a month back, but the days were correct. Thanks for getting back to me. I'll handle it in the javascript Date implementation.

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

No branches or pull requests

2 participants