}
cat = fmt_get_category (format);
- if (cat & (FMT_CAT_BASIC | FMT_CAT_HEXADECIMAL
+ if (cat & (FMT_CAT_BASIC | FMT_CAT_HEXADECIMAL | FMT_CAT_CUSTOM
| FMT_CAT_DATE | FMT_CAT_TIME | FMT_CAT_DATE_COMPONENT))
{
/* We're going to parse these into numbers. For this purpose we want to
output, width, output_encoding);
if (error != NULL)
{
- msg (SW,_("Data is not valid as format %s: %s"),
+ msg (SW, _("Data is not valid as format %s: %s"),
fmt_name (format), error);
free (error);
return false;
{
/* This is equivalent to buf_copy_rpad, except that we posibly
do a character set recoding in the middle. */
- uint8_t *dst = value_str_rw (i->output, i->width);
+ uint8_t *dst = i->output->s;
size_t dst_size = i->width;
const char *src = ss_data (i->input);
size_t src_size = ss_length (i->input);
static char *
parse_AHEX (struct data_in *i)
{
- uint8_t *s = value_str_rw (i->output, i->width);
+ uint8_t *s = i->output->s;
size_t j;
for (j = 0; ; j++)
return xasprintf (_("Day (%ld) must be between 1 and 31."), *day);
}
-/* Parses an integer from the beginning of I.
- Adds SECONDS_PER_UNIT times the absolute value of the integer
- to *TIME.
- If *TIME_SIGN is SIGN_NO_TIME, allows a sign to precede the
- time and sets *TIME_SIGN. Otherwise, does not allow a sign.
- Returns true if successful, false if no integer was present. */
-static char *
-parse_time_units (struct data_in *i, double seconds_per_unit,
- enum time_sign *time_sign, double *time)
-
+/* If *TIME_SIGN is SIGN_NO_TIME, allows a sign to precede the
+ time and sets *TIME_SIGN. Otherwise, does not allow a sign. */
+static void
+parse_time_sign (struct data_in *i, enum time_sign *time_sign)
{
- char *error;
- long units;
-
if (*time_sign == SIGN_NO_TIME)
{
if (ss_match_byte (&i->input, '-'))
*time_sign = SIGN_POSITIVE;
}
}
+}
+
+/* Parses an integer from the beginning of I.
+ Adds SECONDS_PER_UNIT times the absolute value of the integer
+ to *TIME.
+ Returns true if successful, false if no integer was present. */
+static char *
+parse_time_units (struct data_in *i, double seconds_per_unit, double *time)
+
+{
+ char *error;
+ long units;
+
error = parse_int (i, &units, SIZE_MAX);
if (error != NULL)
return error;
error = parse_int (i, &minute, SIZE_MAX);
if (error != NULL)
return error;
- if (minute < 0 || minute > 59)
+ if (i->format != FMT_MTIME && (minute < 0 || minute > 59))
return xasprintf (_("Minute (%ld) must be between 0 and 59."), minute);
*time += 60. * minute;
}
/* Parses DATE, ADATE, EDATE, JDATE, SDATE, QYR, MOYR, KWYR,
- DATETIME, TIME and DTIME formats. */
+ DATETIME, YMDHMS, MTIME, TIME, and DTIME formats. */
static char *
parse_date (struct data_in *i)
{
error = parse_week (i, &yday);
break;
case 'D':
- error = parse_time_units (i, 60. * 60. * 24., &time_sign, &time);
+ parse_time_sign (i, &time_sign);
+ error = parse_time_units (i, 60. * 60. * 24., &time);
break;
case 'H':
- error = parse_time_units (i, 60. * 60., &time_sign, &time);
+ parse_time_sign (i, &time_sign);
+ error = parse_time_units (i, 60. * 60., &time);
break;
case 'M':
+ if (i->format == FMT_MTIME)
+ parse_time_sign (i, &time_sign);
error = parse_minute_second (i, &time);
break;
case '-':
default_result (struct data_in *i)
{
if (fmt_is_string (i->format))
- memset (value_str_rw (i->output, i->width), ' ', i->width);
+ memset (i->output->s, ' ', i->width);
else
i->output->f = settings_get_blanks ();
}