#include "libpspp/assertion.h"
#include "libpspp/message.h"
#include "language/expressions/helpers.h"
+#include "language/lexer/format-parser.h"
#include "language/lexer/value-parser.h"
#include "libpspp/pool.h"
#include "output/driver.h"
char *name = NULL;
char *title = NULL;
+ struct fmt_spec format;
+ bool has_format = false;
struct expression *expr;
dict_create_vector_assert (d, "V", vars, n);
free (vars);
}
+ else if (lex_match_id (lexer, "FORMAT"))
+ {
+ lex_match (lexer, T_EQUALS);
+ if (!parse_format_specifier (lexer, &format)
+ || !fmt_check_output (&format)
+ || !fmt_check_type_compat (&format, VAL_NUMERIC))
+ goto done;
+ has_format = true;
+ }
else
break;
}
case OP_num_vec_elem:
{
double d = expr_evaluate_num (expr, c, 0);
- if (d == SYSMIS)
+ if (has_format)
+ {
+ char *output = data_out (&(const union value) { .f = d },
+ NULL, &format,
+ settings_get_fmt_settings ());
+ output_log ("%s => %s", title, output);
+ free (output);
+ }
+ else if (d == SYSMIS)
output_log ("%s => sysmis", title);
else
output_log ("%s => %.2f", title, d);
AT_CLEANUP
# This test will fail if the current date changes during the test.
-AT_SETUP([system variables - $DATE $DATE11])
+AT_SETUP([system variables - $DATE $DATE11 $JDATE $TIME])
AT_KEYWORDS([expression expressions parse])
# Get the date in the formats that $DATE and $DATE11 support.
date=$(date +%d-%^b-%y)
AT_DATA([parse.sps], [dnl
DEBUG EVALUATE /$DATE.
DEBUG EVALUATE /$DATE11.
+DEBUG EVALUATE FORMAT=DATE9 /$JDATE * 86400.
+DEBUG EVALUATE FORMAT=DATE9 /$TIME.
])
AT_CHECK_UNQUOTED([pspp --testing-mode parse.sps], [0], [dnl
\$DATE => "$date"
\$DATE11 => "$date11"
+
+\$JDATE * 86400 => $date
+
+\$TIME => $date
])
AT_CLEANUP