Skip to content

Commit

Permalink
[fix] edge case in datetime type knob
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriela Seabra committed Mar 25, 2021
1 parent 4a03740 commit d6c9bfc
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions addons/knobs/src/components/types/Date.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ export default class DateType extends Component<DateTypeProps, DateTypeState> {
const [year, month, day] = e.target.value.split('-');
const result = new Date(knob.value);
if (result.getTime()) {
result.setFullYear(parseInt(year, 10));
result.setMonth(parseInt(month, 10) - 1);
result.setDate(parseInt(day, 10));
result.setFullYear(parseInt(year, 10), parseInt(month, 10) - 1, parseInt(day, 10));
if (result.getTime()) {
valid = true;
onChange(result.getTime());
Expand Down

0 comments on commit d6c9bfc

Please sign in to comment.