Beispiel #1
0
/* Get the overall statistics header (label).
 *
 * On success, an string containing the overall header is returned. */
char *
get_overall_header (GHolder * h)
{
  const char *sndfmt = conf.spec_date_time_num_format;
  const char *head = conf.output_stdout ? T_HEAD : T_DASH " - " T_HEAD;
  char *hd = NULL, *start = NULL, *end = NULL, **dates = NULL;

  if (h->idx == 0)
    return xstrdup (head);

  dates = get_visitors_dates (h + VISITORS);

  /* just display the actual dates - no specificity */
  start = get_visitors_date (dates[0], sndfmt, "%d/%b/%Y");
  end = get_visitors_date (dates[h->idx - 1], sndfmt, "%d/%b/%Y");

  hd = xmalloc (snprintf (NULL, 0, "%s (%s - %s)", head, start, end) + 1);
  sprintf (hd, "%s (%s - %s)", head, start, end);

  free (dates);
  free (end);
  free (start);

  return hd;
}
Beispiel #2
0
/* Format the visitors date and replace the current holder value.
 *
 * If the given date is a timestamp, then return.
 * On success, the holder value is replaced with a formatted date. */
static void
data_visitors (GHolder * h)
{
  char *date = NULL, *datum = NULL;

  /* date is already in the 'Ymd' format, no need for additional conversion */
  if (has_timestamp (conf.date_format))
    return;

  /* verify we have a valid date conversion */
  datum = h->items[h->idx].metrics->data;
  date = get_visitors_date (datum, conf.date_format, "%Y%m%d");
  free (datum);

  h->items[h->idx].metrics->data = date;
}