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

Fix week_field generating invalid week numbers (according to W3 and Browser) #22190

Closed
wants to merge 1 commit into from

Conversation

1st8
Copy link
Contributor

@1st8 1st8 commented Nov 5, 2015

Hey guys,

the week_field form helper currently uses %W when converting the input value. This results in week numbers being zero-based, which is invalid according to the W3 spec (http://www.w3.org/TR/html-markup/datatypes.html#form.data.week) and the browser in turn selects the week before the intended week.

The first commit adds a spec to illustrate the correct behavior, not receiving a value of 2015-W00 but expecting the correct 2015-W01.
The second commit fixes this spec by replacing %W with %V, differences according to the ruby doc:

Week number:
  %W - Week number of the year. The week starts with Monday. (00..53)

ISO 8601 week-based year and week number:
  %V - Week number of the week-based year (01..53)

Please let me know if I should fix/squash/append anything, since this is my first rails contribution 🎉

Cheers
Christoph

@rails-bot
Copy link

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @matthewd (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@pixeltrix
Copy link
Contributor

@1st8 nice catch! If you could add a CHANGELOG entry and squash the commits that'd be great.

@pixeltrix pixeltrix assigned pixeltrix and unassigned matthewd Nov 5, 2015
@1st8 1st8 force-pushed the fix/week-field-week-number branch from 582883f to 8dc2af6 Compare November 6, 2015 08:15
@1st8
Copy link
Contributor Author

1st8 commented Nov 6, 2015

Thanks for your feedback, it's done.

pixeltrix added a commit that referenced this pull request Nov 10, 2015
Fix week_field returning invalid value
@pixeltrix pixeltrix closed this Nov 10, 2015
@pixeltrix
Copy link
Contributor

@1st8 sorry, for the delay in merging - I just tweaked the commit message and changelog entry and then merged it in 320b79f. I've also backported it to 4-1-stable (4696e0d) and 4-2-stable (8f6ee25).

@pixeltrix
Copy link
Contributor

@1st8 sorry, forgot to say thanks for you fix 😄

@1st8
Copy link
Contributor Author

1st8 commented Nov 10, 2015

Very nice, thank you. I am happy to contribute! 🍻

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.

None yet

4 participants