Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
selectDay = ( day ) => {
const { withRange } = this.props;
let range = {};
if ( withRange ) {
range = DateUtils.addDayToRange( day, this.state );
// if the range was unselected we fallback to the first available day
if ( range.from === null && range.to === null ) {
range.from = today;
range.to = undefined;
}
if ( range.to && moment( range.to ).isSame( range.from ) ) {
range.to = undefined;
}
} else {
range.from = day;
range.to = undefined;
}
this.setState( this.maybeUpdate( range ), () => {
handleDayClick(e, day) {
const range = DateUtils.addDayToRange(day, this.state)
const self = this
this.setState(range)
// Convert to standard format for display
_.forOwn(range, function(val, key){
if (val) {
let validDate = moment(val).format('L')
self.setState({ [key + 'Temp']: validDate })
// Update store
self.formatAndUpdate(validDate, key)
}
})
}
onSelectDate = date => {
if ( ! this.isValidDate( date ) ) {
return;
}
// DateUtils requires a range object with this shape
const range = this.toDateRange( this.state.startDate, this.state.endDate );
const rawDay = this.momentDateToJsDate( date );
// Calculate the new Date range
const newRange = DateUtils.addDayToRange( rawDay, range );
// Update state to reflect new date range for
// calendar and text inputs
this.setState(
previousState => {
// Update to date or `null` which means "not date"
const newStartDate = isNull( newRange.from )
? NO_DATE_SELECTED_VALUE
: this.nativeDateToMoment( newRange.from );
const newEndDate = isNull( newRange.to )
? NO_DATE_SELECTED_VALUE
: this.nativeDateToMoment( newRange.to );
// Update start/end state values
let newState = {
startDate: newStartDate,
handleDayClick(day) {
const { from } = this.state;
const { multiple, onChange } = this.props;
if (multiple) {
const range = DateUtils.addDayToRange(day, this.state);
onChange(range);
this.setState(range);
} else if (from.getHours() !== 12) {
const newDate = new Date(day.setHours(from.getHours()));
onChange({ from: newDate });
this.setState({ from: newDate });
} else {
onChange({ from: day });
this.setState({ from: day });
}
}
handleDayClick(day, { disabled }) {
if (!disabled) {
const range = DateUtils.addDayToRange(day, this.state);
this.setState(range);
}
}
const handleDayClick = day => {
setDateRange(DateUtils.addDayToRange(day, dateRange))
}
handleDayClick = day => {
const range = DateUtils.addDayToRange(day, this.state);
this.setState(range);
};
handleDayClick = day => {
const range = DateUtils.addDayToRange(day, this.state);
this.setState(range);
};
handleDayClick(day) {
const range = DateUtils.addDayToRange(day, this.state);
this.setState(range);
}