Skip to content

Commit

Permalink
Validation updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Merve7 committed Mar 3, 2020
1 parent 99a1509 commit fc24216
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/components/calendar/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -663,9 +663,9 @@ export class Calendar extends Component {
const currentTime = (this.props.value && this.props.value instanceof Date) ? this.props.value : this.getViewDate();
const currentHour = currentTime.getHours();
let newHour = currentHour + this.props.stepHour;
newHour = (newHour >= 24) ? (newHour - 24) : newHour;

if (this.validateHour(newHour, currentTime)) {
newHour = (newHour >= 24) ? (newHour - 24) : newHour;
this.updateTime(event, newHour, currentTime.getMinutes(), currentTime.getSeconds());
}

Expand All @@ -676,9 +676,9 @@ export class Calendar extends Component {
const currentTime = (this.props.value && this.props.value instanceof Date) ? this.props.value : this.getViewDate();
const currentHour = currentTime.getHours();
let newHour = currentHour - this.props.stepHour;
newHour = (newHour < 0) ? (newHour + 24) : newHour;

if (this.validateHour(newHour, currentTime)) {
newHour = (newHour < 0) ? (newHour + 24) : newHour;
this.updateTime(event, newHour, currentTime.getMinutes(), currentTime.getSeconds());
}

Expand All @@ -689,9 +689,9 @@ export class Calendar extends Component {
const currentTime = (this.props.value && this.props.value instanceof Date) ? this.props.value : this.getViewDate();
const currentMinute = currentTime.getMinutes();
let newMinute = currentMinute + this.props.stepMinute;
newMinute = (newMinute > 59) ? (newMinute - 60) : newMinute;

if (this.validateMinute(newMinute, currentTime)) {
newMinute = (newMinute > 59) ? (newMinute - 60) : newMinute;
this.updateTime(event, currentTime.getHours(), newMinute, currentTime.getSeconds());
}

Expand All @@ -702,9 +702,9 @@ export class Calendar extends Component {
const currentTime = (this.props.value && this.props.value instanceof Date) ? this.props.value : this.getViewDate();
const currentMinute = currentTime.getMinutes();
let newMinute = currentMinute - this.props.stepMinute;
newMinute = (newMinute < 0) ? (newMinute + 60) : newMinute;

if (this.validateMinute(newMinute, currentTime)) {
newMinute = (newMinute < 0) ? (newMinute + 60) : newMinute;
this.updateTime(event, currentTime.getHours(), newMinute, currentTime.getSeconds());
}

Expand All @@ -715,9 +715,9 @@ export class Calendar extends Component {
const currentTime = (this.props.value && this.props.value instanceof Date) ? this.props.value : this.getViewDate();
const currentSecond = currentTime.getSeconds();
let newSecond = currentSecond + this.props.stepSecond;
newSecond = (newSecond > 59) ? (newSecond - 60) : newSecond;

if (this.validateSecond(newSecond, currentTime)) {
newSecond = (newSecond > 59) ? (newSecond - 60) : newSecond;
this.updateTime(event, currentTime.getHours(), currentTime.getMinutes(), newSecond);
}

Expand All @@ -728,9 +728,9 @@ export class Calendar extends Component {
const currentTime = (this.props.value && this.props.value instanceof Date) ? this.props.value : this.getViewDate();
const currentSecond = currentTime.getSeconds();
let newSecond = currentSecond - this.props.stepSecond;
newSecond = (newSecond < 0) ? (newSecond + 60) : newSecond;

if (this.validateSecond(newSecond, currentTime)) {
newSecond = (newSecond < 0) ? (newSecond + 60) : newSecond;
this.updateTime(event, currentTime.getHours(), currentTime.getMinutes(), newSecond);
}

Expand Down Expand Up @@ -798,15 +798,15 @@ export class Calendar extends Component {

if(this.props.minDate && valueDateString && this.props.minDate.toDateString() === valueDateString) {
if(value.getHours() === this.props.minDate.getHours() && value.getMinutes() === this.props.minDate.getMinutes()) {
if(this.props.minDate.getMinutes() > second) {
if(this.props.minDate.getSeconds() > second) {
valid = false;
}
}
}

if(this.props.maxDate && valueDateString && this.props.maxDate.toDateString() === valueDateString) {
if(value.getHours() === this.props.maxDate.getHours() && value.getMinutes() === this.props.maxDate.getMinutes()){
if(this.props.maxDate.getMinutes() < second) {
if(this.props.maxDate.getSeconds() < second) {
valid = false;
}
}
Expand Down

0 comments on commit fc24216

Please sign in to comment.