UNPKG

@cloudgakkai/react-native-date-ranges

Version:

[![npm version](https://img.shields.io/npm/v/react-native-date-ranges.svg?style=flat-square)](https://www.npmjs.com/package/react-native-date-ranges) [![npm downloads](https://img.shields.io/npm/dm/react-native-date-ranges.svg?style=flat-square)](https://

17 lines (15 loc) 579 B
export const dates = (startDate, endDate, focusedInput ) => { if (focusedInput === 'startDate') { if (startDate && endDate) { return ({ startDate, endDate: null, focusedInput: 'endDate' }); } return ({ startDate, endDate, focusedInput: 'endDate' }); } if (focusedInput === 'endDate') { if (endDate && startDate && endDate.isBefore(startDate)) { return ({ startDate: endDate, endDate: null, focusedInput: 'endDate' }); } return ({ startDate, endDate, focusedInput: 'startDate' }); } return ({ startDate, endDate, focusedInput }); };