Out of office replies: backport some code changes from upstreamed patch

Most notable change is that the UI for dates will be hidden when server does not
support it, not just disabled.

Also detection of whether the script is still active got smarter and will not consider
the script active if the date range is in past or future.

Additionally, some const stuff and minor refactoring.