-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
exclude time from default date widget format #1143
Conversation
Deploy preview for netlify-cms-www ready! Built with commit cc30539 |
Deploy preview for cms-demo ready! Built with commit cc30539 |
@@ -42,7 +42,7 @@ export default class DateControl extends React.Component { | |||
|
|||
render() { | |||
const { includeTime, value, classNameWrapper, setActiveStyle, setInactiveStyle } = this.props; | |||
const format = this.format || moment.defaultFormat; | |||
const format = this.format || moment[includeTime ? 'defaultFormat' : 'HTML5_FMT.DATE']; |
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.
'HTML5_FMT.DATE'
won't work as it's not a key name, since DATE
is a property of HTML5_FMT
.
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.
const format = this.format || (includeTime ? moment.defaultFormat : moment.HTML5_FMT.DATE);
should work (not tested)
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.
Good catch! 🤦♂️
I'm assuming this shouldn't be classified as a breaking change if we're just changing it to match our docs? It is changing the output of pre-existing entries, though. |
Right not, breaking, just a bugfix. This is the documented behavior and we weren't doing it. |
@tech4him1 fixed. |
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.
Code looks great! However, HTML5_FMT.DATE wasn't added until Moment 2.20.0, and we're on 2.11.2, so that will need updated as well.
Drat. |
@tech4him1 fixed 4 realz. |
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.
LGTM. I take it you don't want to upgrade Moment. :)
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.
Just noticed that our value in Redux is still the ISO format, not the actual formatted value that we want. The file that is output has the correct format, but the preview will not. Thoughts?
@erquhart I went ahead and pushed a commit to save the formatted value in Redux, feel free to revert if you don't like it. 😄 |
@tech4him1 much better place to do it, thank you. |
BREAKING CHANGE As of 1.0, the documented behavior for the date and datetime widgets was to always return a string value, but they were instead returning a date object if the default date was not manually changed by the user. This was addressed in #1143, but it became clear afterward that static site generators were depending on the raw date objects that Netlify CMS was unintentionally producing. Remaining as is or addressing the bug were both "breaking" states, so this commit reverts to producing raw date objects when no format is explicitly set. It is now considered an edge case to require string dates, as most static site generators expect to parse a raw date against formatting in a site's templates. Also note that this commit improves the original behavior by always providing a date object when no format is provided, even if the user manually changes the value.
BREAKING CHANGE As of 1.0, the documented behavior for the date and datetime widgets was to always return a string value, but they were instead returning a date object if the default date was not manually changed by the user. This was addressed in #1143, but it became clear afterward that static site generators were depending on the raw date objects that Netlify CMS was unintentionally producing. Remaining as is or addressing the bug were both "breaking" states, so this commit reverts to producing raw date objects when no format is explicitly set. It is now considered an edge case to require string dates, as most static site generators expect to parse a raw date against formatting in a site's templates. Also note that this commit improves the original behavior by always providing a date object when no format is provided, even if the user manually changes the value.
BREAKING CHANGE As of 1.0, the documented behavior for the date and datetime widgets was to always return a string value, but they were instead returning a date object if the default date was not manually changed by the user. This was addressed in #1143, but it became clear afterward that static site generators were depending on the raw date objects that Netlify CMS was unintentionally producing. Remaining as is or addressing the bug were both "breaking" states, so this commit reverts to producing raw date objects when no format is explicitly set. It is now considered an edge case to require string dates, as most static site generators expect to parse a raw date against formatting in a site's templates. Also note that this commit improves the original behavior by always providing a date object when no format is provided, even if the user manually changes the value.
BREAKING CHANGE As of 1.0, the documented behavior for the date and datetime widgets was to always return a string value, but they were instead returning a date object if the default date was not manually changed by the user. This was addressed in #1143, but it became clear afterward that static site generators were depending on the raw date objects that Netlify CMS was unintentionally producing. Remaining as is or addressing the bug were both "breaking" states, so this commit reverts to producing raw date objects when no format is explicitly set. It is now considered an edge case to require string dates, as most static site generators expect to parse a raw date against formatting in a site's templates. Also note that this commit improves the original behavior by always providing a date object when no format is provided, even if the user manually changes the value.
BREAKING CHANGE As of 1.0, the documented behavior for the date and datetime widgets was to always return a string value, but they were instead returning a date object if the default date was not manually changed by the user. This was addressed in #1143, but it became clear afterward that static site generators were depending on the raw date objects that Netlify CMS was unintentionally producing. Remaining as is or addressing the bug were both "breaking" states, so this commit reverts to producing raw date objects when no format is explicitly set. It is now considered an edge case to require string dates, as most static site generators expect to parse a raw date against formatting in a site's templates. Also note that this commit improves the original behavior by always providing a date object when no format is provided, even if the user manually changes the value.
* return date object from date/datetime widgets if no format set BREAKING CHANGE As of 1.0, the documented behavior for the date and datetime widgets was to always return a string value, but they were instead returning a date object if the default date was not manually changed by the user. This was addressed in #1143, but it became clear afterward that static site generators were depending on the raw date objects that Netlify CMS was unintentionally producing. Remaining as is or addressing the bug were both "breaking" states, so this commit reverts to producing raw date objects when no format is explicitly set. It is now considered an edge case to require string dates, as most static site generators expect to parse a raw date against formatting in a site's templates. Also note that this commit improves the original behavior by always providing a date object when no format is provided, even if the user manually changes the value. * produce raw date when no format is provided
…org#1296) * return date object from date/datetime widgets if no format set BREAKING CHANGE As of 1.0, the documented behavior for the date and datetime widgets was to always return a string value, but they were instead returning a date object if the default date was not manually changed by the user. This was addressed in decaporg#1143, but it became clear afterward that static site generators were depending on the raw date objects that Netlify CMS was unintentionally producing. Remaining as is or addressing the bug were both "breaking" states, so this commit reverts to producing raw date objects when no format is explicitly set. It is now considered an edge case to require string dates, as most static site generators expect to parse a raw date against formatting in a site's templates. Also note that this commit improves the original behavior by always providing a date object when no format is provided, even if the user manually changes the value. * produce raw date when no format is provided
…org#1296) * return date object from date/datetime widgets if no format set BREAKING CHANGE As of 1.0, the documented behavior for the date and datetime widgets was to always return a string value, but they were instead returning a date object if the default date was not manually changed by the user. This was addressed in decaporg#1143, but it became clear afterward that static site generators were depending on the raw date objects that Netlify CMS was unintentionally producing. Remaining as is or addressing the bug were both "breaking" states, so this commit reverts to producing raw date objects when no format is explicitly set. It is now considered an edge case to require string dates, as most static site generators expect to parse a raw date against formatting in a site's templates. Also note that this commit improves the original behavior by always providing a date object when no format is provided, even if the user manually changes the value. * produce raw date when no format is provided
Sets correct and documented format for Date widget (YYYY-MM-DD).
Closes #1119.