Add support for limiting time range

Command line options --time-start=[time] and --time-end=[time] are now
implemented to limit the results output by the 'downtime', 'uptime',
'all-data' and 'summary' commands. [time] must be a valid Unix time. In the
absence of an explicit setting, they default to the first recorded time and
the last recorded time for time-start and time-end respectively
Code cleanup

Reduce length of many variables by using 'local' inside functions.