Commit c4e4f8d2 authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

New function. (do_af_suggest): Be smarter about date differences. They're

2003-07-14  Morten Welinder  <terra@gnome.org>

	* src/auto-format.c (is_date): New function.
	(do_af_suggest): Be smarter about date differences.  They're
	common and formatting them as dates is irritating.
parent 90e25962
2003-07-14 Morten Welinder <terra@gnome.org>
* src/auto-format.c (is_date): New function.
(do_af_suggest): Be smarter about date differences. They're
common and formatting them as dates is irritating.
2003-07-13 Andreas J. Guelzow <aguelzow@taliesin.ca> 2003-07-13 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/commands.c (cmd_analysis_tool_redo): recalc * src/commands.c (cmd_analysis_tool_redo): recalc
......
...@@ -99,6 +99,7 @@ Morten: ...@@ -99,6 +99,7 @@ Morten:
* Fix +/- buttons for currency formats. * Fix +/- buttons for currency formats.
* Make the 1000-separator button do something more useful. * Make the 1000-separator button do something more useful.
* Improve the support for fractional formats. * Improve the support for fractional formats.
* Improve auto-format for date differences.
-------------------------------------------------------------------------- --------------------------------------------------------------------------
......
2003-07-14 Morten Welinder <terra@gnome.org>
* src/auto-format.c (is_date): New function.
(do_af_suggest): Be smarter about date differences. They're
common and formatting them as dates is irritating.
2003-07-13 Andreas J. Guelzow <aguelzow@taliesin.ca> 2003-07-13 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/commands.c (cmd_analysis_tool_redo): recalc * src/commands.c (cmd_analysis_tool_redo): recalc
......
2003-07-14 Morten Welinder <terra@gnome.org>
* src/auto-format.c (is_date): New function.
(do_af_suggest): Be smarter about date differences. They're
common and formatting them as dates is irritating.
2003-07-13 Andreas J. Guelzow <aguelzow@taliesin.ca> 2003-07-13 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/commands.c (cmd_analysis_tool_redo): recalc * src/commands.c (cmd_analysis_tool_redo): recalc
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "sheet.h" #include "sheet.h"
#include "workbook.h" #include "workbook.h"
#include "format.h" #include "format.h"
#include "formats.h"
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
/* /*
...@@ -79,6 +80,21 @@ cb_af_suggest (G_GNUC_UNUSED Sheet *sheet, ...@@ -79,6 +80,21 @@ cb_af_suggest (G_GNUC_UNUSED Sheet *sheet,
return NULL; return NULL;
} }
static gboolean
is_date (GnmFuncFlags typ, StyleFormat *explicit)
{
switch (typ) {
case GNM_FUNC_AUTO_DATE: return TRUE;
default: return FALSE;
case AF_EXPLICIT: {
FormatCharacteristics info;
return (cell_format_classify (explicit, &info) == FMT_DATE);
}
}
}
static GnmFuncFlags static GnmFuncFlags
do_af_suggest (GnmExpr const *expr, const EvalPos *epos, StyleFormat **explicit) do_af_suggest (GnmExpr const *expr, const EvalPos *epos, StyleFormat **explicit)
{ {
...@@ -111,7 +127,7 @@ do_af_suggest (GnmExpr const *expr, const EvalPos *epos, StyleFormat **explicit) ...@@ -111,7 +127,7 @@ do_af_suggest (GnmExpr const *expr, const EvalPos *epos, StyleFormat **explicit)
typ1 = do_af_suggest (expr->binary.value_a, epos, &explicit1); typ1 = do_af_suggest (expr->binary.value_a, epos, &explicit1);
typ2 = do_af_suggest (expr->binary.value_b, epos, &explicit2); typ2 = do_af_suggest (expr->binary.value_b, epos, &explicit2);
if (typ1 == GNM_FUNC_AUTO_DATE && typ2 == GNM_FUNC_AUTO_DATE) if (is_date (typ1, explicit1) && is_date (typ2, explicit2))
return GNM_FUNC_AUTO_UNITLESS; return GNM_FUNC_AUTO_UNITLESS;
else if (typ1 != GNM_FUNC_AUTO_UNKNOWN && typ1 != GNM_FUNC_AUTO_UNITLESS) { else if (typ1 != GNM_FUNC_AUTO_UNKNOWN && typ1 != GNM_FUNC_AUTO_UNITLESS) {
*explicit = explicit1; *explicit = explicit1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment