The UI code must validate start - end times and calculate the duration only if their values are valid. If not valid a 'Not Available!' could be displayed.
Following validations must be done:
- Start time must be a number greater than 0
- End time must be a number greater than 0
- End time must be greater than or equal to start time