/* PSPP - a program for statistical analysis.
- Copyright (C) 2008, 2010 Free Software Foundation, Inc.
+ Copyright (C) 2008, 2010, 2011 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <config.h>
-#include "format-guesser.h"
+#include "data/format-guesser.h"
#include <stdlib.h>
#include <string.h>
-#include "c-ctype.h"
-#include "minmax.h"
-#include "xalloc.h"
+#include "data/format.h"
+#include "data/settings.h"
+#include "libpspp/assertion.h"
+#include "libpspp/str.h"
-#include <data/format.h>
-#include <data/settings.h>
-#include <libpspp/assertion.h>
-#include <libpspp/str.h>
+#include "gl/c-ctype.h"
+#include "gl/minmax.h"
+#include "gl/xalloc.h"
/* A token in which potential date or time fields are broken.
11, {DT_DAY, DT_DELIM, DT_MONTH, DT_DELIM, DT_YEAR, DT_SPACE, DT_HOUR,
DT_COLON, DT_MINUTE, DT_COLON, DT_SECOND} },
+ /* yyyy-dd-mmm HH:MM */
+ { FMT_YMDHMS,
+ 9, {DT_YEAR, DT_DELIM, DT_MONTH, DT_DELIM, DT_DAY, DT_SPACE, DT_HOUR,
+ DT_COLON, DT_MINUTE} },
+ /* yyyy-dd-mmm HH:MM:SS */
+ { FMT_YMDHMS,
+ 11, {DT_YEAR, DT_DELIM, DT_MONTH, DT_DELIM, DT_DAY, DT_SPACE, DT_HOUR,
+ DT_COLON, DT_MINUTE, DT_COLON, DT_SECOND} },
+
/* HH:MM */
{ FMT_TIME, 3, {DT_HOUR, DT_COLON, DT_MINUTE} },
/* HH:MM:SS */
}
\f
/* Tries to parse S as a date (DATE, ADATE, EDATE, SDATE, QYR,
- MOYR, WKYR, or DATETIME), time (TIME or DTIME), or date
- component (WKDAY or MONTH) format. If successful, increments
- G's any_date counter and the counter or counters for the
- specific format(s) that S matches. On failure, does not
- modify G.
+ MOYR, WKYR, DATETIME, or YMDHMS), time (TIME or DTIME), or
+ date component (WKDAY or MONTH) format. If successful,
+ increments G's any_date counter and the counter or counters
+ for the specific format(s) that S matches. On failure, does
+ not modify G.
+
+ XXX How can we distinguish MTIME from TIME? One way might be
+ that TIME can have three parts (HH:MM:SS) but MTIME only ever
+ has two (MM:SS).
Does not attempt to recognize JDATE format: it looks just like
F format and will thus be caught by the numeric parser.
(We use the minimum input width, but an output width would
be equally appropriate, since all the time formats have the
same minimum widths for input and output.) */
- if (f->type == FMT_DATETIME || f->type == FMT_TIME
- || f->type == FMT_DTIME)
+ if (f->type == FMT_DATETIME || f->type == FMT_YMDHMS
+ || f->type == FMT_MTIME || f->type == FMT_TIME || f->type == FMT_DTIME)
{
for (i = 0; i < DATE_SYNTAX_CNT; i++)
if (g->date[i]