Skip to content

Commit

Permalink
Fix: Allow years lower than 1970 in DateTime component. (#13602)
Browse files Browse the repository at this point in the history
## Description
Fixes: #13579

This PR changes the DateTime component to allow years between 0 and 1970 that were previously unallowed.
The classic editor allows this set of years so we are updating the component to be equivalent.
Years lower than 0 and greater than 9999 are not allowed because JS error happens inside moment functions if these years are used. The classic editor and the quick edit form also don't allow this set of years.

## How has this been tested?
I checked I'm able to use years between  0 and 1970 on the publish date field with success
  • Loading branch information
jorgefilipecosta authored and youknowriad committed Mar 6, 2019
1 parent e0b4b3b commit 78747a5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
### Bug Fixes

- Resolves a conflict where two instance of Slot would produce an inconsistent or duplicated rendering output.
- Allow years between 0 and 1970 in DateTime component.

### New Feature

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/date-time/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class TimePicker extends Component {
const { onChange } = this.props;
const { year, date } = this.state;
const value = parseInt( year, 10 );
if ( ! isInteger( value ) || value < 1970 || value > 9999 ) {
if ( ! isInteger( value ) || value < 0 || value > 9999 ) {
this.syncState( this.props );
return;
}
Expand Down

0 comments on commit 78747a5

Please sign in to comment.