I think you can move this check to line 221

```
if (typeof option === "undefined" || option == "today" || option == "")
```