Add Task date time picker - peophins-plasmas/pawsome-app GitHub Wiki
https://www.npmjs.com/package/@react-native-community/datetimepicker
- Used the 'datetime' mode since we need both date and time
- Display is default
- width set to 220 based on research from StackOverflow to fully display date
- value is the initial value shown, which is set to the date through selDate state
- On change function:
const onChange = (event, value) => {
setDueDate(value.toDateString());
const time = value.toLocaleTimeString();
setEntityDueTime(time);
setSelDate(value);
};
- value is a timestamp; toDateString ensures correct formatting for sorting and querying Firebase
- selDate is a timestamp, stands for selected date from calendar
- dueDate is a date string, for displaying day tasks are due
- entityDueTime is a timestring, hours:min:second, for displaying time task is due