-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Adds ability to use a custom date format #46
Conversation
@@ -82,6 +82,7 @@ var DatePicker = React.createClass({ | |||
<div> | |||
<DateInput | |||
date={this.props.selected} | |||
dateFormat={this.props.dateFormat || 'YYYY-MM-DD'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's default to YYYY-MM-DD
by setting it in getDefaultProps
.
Awesome! Thanks for submitting this. I have two minor comments, after that I think this is good to go. |
@RSO no problem! This should be ready to merge. |
Sorry for getting back to you so late, but I've just discovered a problem with this pull request. A while ago I added a functionality that would increment/decrement the part of the date which your cursor highlighted. This no longer works properly when you change the dateFormat, because of all the implicit dependencies on the dateFormat.. The way I see it there are two things we could do here:
I'd vote for 1. What do you think? |
@@ -254,6 +254,12 @@ var DatePicker = React.createClass({displayName: 'DatePicker', | |||
}; | |||
}, | |||
|
|||
getDefaultProps: function() { | |||
return { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation level on these lines are 4 spaces instead of 2.
I will try to dig in as soon as I have a chance. Probably within the next 5 days. This is a valid concern and a nice feature of the plugin. After a quick glance at the code, I think we should be able to re-parse out the year/month/day based on the keydown event target and retain the current functionality...since the date format string is available as a prop. I think what I just described is pretty much #2. Anyways, I think I would have a go at that before resorting to removing some of the value-add functionality and implementing #1. Thanks for the input! |
Closing this since #48 is already merged. |
A date format string can be entered as the prop
dateFormat
to theDatePicker
element. If you do not enter this prop, it will default toYYYY-MM-DD
, which was previously the only valid format allowed. The requirements of one of my current projects was that I needed a different format, so I put in the issue #45. Please let me know if you have any questions. Thanks!