-static int get_time_args (graph_data_t *data) /* {{{ */
-{
- const char *begin_str;
- const char *end_str;
- long now;
- long begin;
- long end;
- char *endptr;
- long tmp;
-
- begin_str = param ("begin");
- end_str = param ("end");
-
- now = (long) time (NULL);
- data->now = now;
- data->begin = now - 86400;
- data->end = now;
-
- if (begin_str != NULL)
- {
- endptr = NULL;
- errno = 0;
- tmp = strtol (begin_str, &endptr, /* base = */ 0);
- if ((endptr == begin_str) || (errno != 0))
- return (-1);
- if (tmp <= 0)
- begin = now + tmp;
- else
- begin = tmp;
- }
- else /* if (begin_str == NULL) */
- {
- begin = now - 86400;
- }
-
- if (end_str != NULL)
- {
- endptr = NULL;
- errno = 0;
- tmp = strtol (end_str, &endptr, /* base = */ 0);
- if ((endptr == end_str) || (errno != 0))
- return (-1);
- end = tmp;
- if (tmp <= 0)
- end = now + tmp;
- else
- end = tmp;
- }
- else /* if (end_str == NULL) */
- {
- end = now;
- }
-
- if (begin == end)
- return (-1);
-
- if (begin > end)
- {
- tmp = begin;
- begin = end;
- end = tmp;
- }
-
- data->begin = begin;
- data->end = end;
-
- array_append (data->args->options, "-s");
- array_append_format (data->args->options, "%li", begin);
- array_append (data->args->options, "-e");
- array_append_format (data->args->options, "%li", end);
-
- return (0);
-} /* }}} int get_time_args */
-