Commit a93b05ca authored by Morten Welinder's avatar Morten Welinder

Compilation: catch up with goffice.

parent bd6234d8
...@@ -475,7 +475,7 @@ xl_xml_data_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob) ...@@ -475,7 +475,7 @@ xl_xml_data_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
g_date_clear (&date, 1); g_date_clear (&date, 1);
g_date_set_dmy (&date, d, mo, y); g_date_set_dmy (&date, d, mo, y);
if (g_date_valid (&date)) { if (g_date_valid (&date)) {
unsigned d_serial = datetime_g_to_serial (&date, unsigned d_serial = go_date_g_to_serial (&date,
workbook_date_conv (state->wb)); workbook_date_conv (state->wb));
v = value_new_float (d_serial + h/24. + mi/(24.*60.) + s/(24.*60.*60.)); v = value_new_float (d_serial + h/24. + mi/(24.*60.) + s/(24.*60.*60.));
} else } else
......
...@@ -147,7 +147,7 @@ xls_read_pivot_cache_value (XLSReadPivot *s, BiffQuery *q) ...@@ -147,7 +147,7 @@ xls_read_pivot_cache_value (XLSReadPivot *s, BiffQuery *q)
g_date_set_dmy (&date, d, m, y); g_date_set_dmy (&date, d, m, y);
if (g_date_valid (&date)) { if (g_date_valid (&date)) {
unsigned d_serial = datetime_g_to_serial (&date, unsigned d_serial = go_date_g_to_serial (&date,
workbook_date_conv (s->imp->wb)); workbook_date_conv (s->imp->wb));
double time_frac = h + ((double)mi / 60.) + ((double)se / 3600.); double time_frac = h + ((double)mi / 60.) + ((double)se / 3600.);
GnmValue *res = value_new_float (d_serial + time_frac / 24.); GnmValue *res = value_new_float (d_serial + time_frac / 24.);
......
...@@ -546,7 +546,7 @@ attr_datetime (GsfXMLIn *xin, xmlChar const **attrs, ...@@ -546,7 +546,7 @@ attr_datetime (GsfXMLIn *xin, xmlChar const **attrs,
g_date_set_dmy (&date, d, m, y); g_date_set_dmy (&date, d, m, y);
if (g_date_valid (&date)) { if (g_date_valid (&date)) {
XLSXReadState *state = (XLSXReadState *)xin->user_state; XLSXReadState *state = (XLSXReadState *)xin->user_state;
unsigned d_serial = datetime_g_to_serial (&date, unsigned d_serial = go_date_g_to_serial (&date,
workbook_date_conv (state->wb)); workbook_date_conv (state->wb));
if (n >= 6) { if (n >= 6) {
double time_frac = h + ((double)mi / 60.) + ((double)s / 3600.); double time_frac = h + ((double)mi / 60.) + ((double)s / 3600.);
......
...@@ -121,7 +121,7 @@ gnumeric_date (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -121,7 +121,7 @@ gnumeric_date (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
g_date_get_year (&date) >= 11900) g_date_get_year (&date) >= 11900)
goto error; goto error;
return make_date (value_new_int (datetime_g_to_serial (&date, conv))); return make_date (value_new_int (go_date_g_to_serial (&date, conv)));
error: error:
return value_new_error_NUM (ei->pos); return value_new_error_NUM (ei->pos);
...@@ -149,7 +149,7 @@ gnumeric_unix2date (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -149,7 +149,7 @@ gnumeric_unix2date (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
if (gnm_abs (futime - utime) >= 1.0) if (gnm_abs (futime - utime) >= 1.0)
return value_new_error_VALUE (ei->pos); return value_new_error_VALUE (ei->pos);
serial = datetime_timet_to_serial_raw (utime, DATE_CONV (ei->pos)); serial = go_date_timet_to_serial_raw (utime, DATE_CONV (ei->pos));
if (serial == G_MAXINT) if (serial == G_MAXINT)
return value_new_error_VALUE (ei->pos); return value_new_error_VALUE (ei->pos);
...@@ -173,7 +173,7 @@ gnumeric_date2unix (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -173,7 +173,7 @@ gnumeric_date2unix (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{ {
gnm_float fserial = value_get_as_float (argv [0]); gnm_float fserial = value_get_as_float (argv [0]);
int serial = (int)fserial; int serial = (int)fserial;
time_t utime = datetime_serial_to_timet (serial, DATE_CONV (ei->pos)); time_t utime = go_date_serial_to_timet (serial, DATE_CONV (ei->pos));
/* Check for overflow. */ /* Check for overflow. */
if (gnm_abs (fserial - serial) >= 1.0 || utime == (time_t)-1) if (gnm_abs (fserial - serial) >= 1.0 || utime == (time_t)-1)
...@@ -226,7 +226,7 @@ datedif_opt_ym (GDate *gdate1, GDate *gdate2) ...@@ -226,7 +226,7 @@ datedif_opt_ym (GDate *gdate1, GDate *gdate2)
g_assert (g_date_valid (gdate1)); g_assert (g_date_valid (gdate1));
g_assert (g_date_valid (gdate2)); g_assert (g_date_valid (gdate2));
return datetime_g_months_between (gdate1, gdate2) % 12; return go_date_g_months_between (gdate1, gdate2) % 12;
} }
static int static int
...@@ -240,7 +240,7 @@ datedif_opt_yd (GDate *gdate1, GDate *gdate2, int excel_compat) ...@@ -240,7 +240,7 @@ datedif_opt_yd (GDate *gdate1, GDate *gdate2, int excel_compat)
day = g_date_get_day (gdate1); day = g_date_get_day (gdate1);
gnm_date_add_years (gdate1, gnm_date_add_years (gdate1,
datetime_g_years_between (gdate1, gdate2)); go_date_g_years_between (gdate1, gdate2));
/* according to glib.h, feb 29 turns to feb 28 if necessary */ /* according to glib.h, feb 29 turns to feb 28 if necessary */
if (excel_compat) { if (excel_compat) {
...@@ -279,7 +279,7 @@ datedif_opt_md (GDate *gdate1, GDate *gdate2, gboolean excel_compat) ...@@ -279,7 +279,7 @@ datedif_opt_md (GDate *gdate1, GDate *gdate2, gboolean excel_compat)
day = g_date_get_day (gdate1); day = g_date_get_day (gdate1);
gnm_date_add_months (gdate1, gnm_date_add_months (gdate1,
datetime_g_months_between (gdate1, gdate2)); go_date_g_months_between (gdate1, gdate2));
/* according to glib.h, days>28 decrease if necessary */ /* according to glib.h, days>28 decrease if necessary */
if (excel_compat) { if (excel_compat) {
...@@ -322,15 +322,15 @@ gnumeric_datedif (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -322,15 +322,15 @@ gnumeric_datedif (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
if (!strcmp (opt, "d")) if (!strcmp (opt, "d"))
return value_new_int (date2 - date1); return value_new_int (date2 - date1);
datetime_serial_to_g (&d1, date1, conv); go_date_serial_to_g (&d1, date1, conv);
datetime_serial_to_g (&d2, date2, conv); go_date_serial_to_g (&d2, date2, conv);
if (!g_date_valid (&d1) || !g_date_valid (&d2)) if (!g_date_valid (&d1) || !g_date_valid (&d2))
return value_new_error_VALUE (ei->pos); return value_new_error_VALUE (ei->pos);
if (!strcmp (opt, "m")) if (!strcmp (opt, "m"))
return value_new_int (datetime_g_months_between (&d1, &d2)); return value_new_int (go_date_g_months_between (&d1, &d2));
else if (!strcmp (opt, "y")) else if (!strcmp (opt, "y"))
return value_new_int (datetime_g_years_between (&d1, &d2)); return value_new_int (go_date_g_years_between (&d1, &d2));
else if (!strcmp (opt, "ym")) else if (!strcmp (opt, "ym"))
return value_new_int (datedif_opt_ym (&d1, &d2)); return value_new_int (datedif_opt_ym (&d1, &d2));
else if (!strcmp (opt, "yd")) else if (!strcmp (opt, "yd"))
...@@ -367,7 +367,7 @@ gnumeric_edate (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -367,7 +367,7 @@ gnumeric_edate (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
if (months > INT_MAX / 2 || -months > INT_MAX / 2) if (months > INT_MAX / 2 || -months > INT_MAX / 2)
return value_new_error_NUM (ei->pos); return value_new_error_NUM (ei->pos);
datetime_serial_to_g (&date, (int)serial, conv); go_date_serial_to_g (&date, (int)serial, conv);
gnm_date_add_months (&date, (int)months); gnm_date_add_months (&date, (int)months);
if (!g_date_valid (&date) || if (!g_date_valid (&date) ||
...@@ -375,7 +375,7 @@ gnumeric_edate (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -375,7 +375,7 @@ gnumeric_edate (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
g_date_get_year (&date) > 9999) g_date_get_year (&date) > 9999)
return value_new_error_NUM (ei->pos); return value_new_error_NUM (ei->pos);
return make_date (value_new_int (datetime_g_to_serial (&date, conv))); return make_date (value_new_int (go_date_g_to_serial (&date, conv)));
} }
/***************************************************************************/ /***************************************************************************/
...@@ -392,7 +392,7 @@ static GnmFuncHelp const help_today[] = { ...@@ -392,7 +392,7 @@ static GnmFuncHelp const help_today[] = {
static GnmValue * static GnmValue *
gnumeric_today (GnmFuncEvalInfo *ei, GnmValue const * const *argv) gnumeric_today (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{ {
return make_date (value_new_int (datetime_timet_to_serial (time (NULL), DATE_CONV (ei->pos)))); return make_date (value_new_int (go_date_timet_to_serial (time (NULL), DATE_CONV (ei->pos))));
} }
/***************************************************************************/ /***************************************************************************/
...@@ -409,7 +409,7 @@ static GnmFuncHelp const help_now[] = { ...@@ -409,7 +409,7 @@ static GnmFuncHelp const help_now[] = {
static GnmValue * static GnmValue *
gnumeric_now (GnmFuncEvalInfo *ei, GnmValue const * const *argv) gnumeric_now (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{ {
return value_new_float (datetime_timet_to_serial_raw (time (NULL), DATE_CONV (ei->pos))); return value_new_float (go_date_timet_to_serial_raw (time (NULL), DATE_CONV (ei->pos)));
} }
/***************************************************************************/ /***************************************************************************/
...@@ -659,7 +659,7 @@ static GnmFuncHelp const help_days360[] = { ...@@ -659,7 +659,7 @@ static GnmFuncHelp const help_days360[] = {
static GnmValue * static GnmValue *
gnumeric_days360 (GnmFuncEvalInfo *ei, GnmValue const * const *argv) gnumeric_days360 (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{ {
basis_t basis; go_basis_t basis;
GDate date1, date2; GDate date1, date2;
GODateConventions const *date_conv = DATE_CONV (ei->pos); GODateConventions const *date_conv = DATE_CONV (ei->pos);
gnm_float serial1 = datetime_value_to_serial (argv[0], date_conv); gnm_float serial1 = datetime_value_to_serial (argv[0], date_conv);
...@@ -667,18 +667,18 @@ gnumeric_days360 (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -667,18 +667,18 @@ gnumeric_days360 (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
gnm_float method = argv[2] ? gnm_floor (value_get_as_float (argv[2])) : 0; gnm_float method = argv[2] ? gnm_floor (value_get_as_float (argv[2])) : 0;
switch ((int)method) { switch ((int)method) {
case 0: basis = BASIS_MSRB_30_360; break; case 0: basis = GO_BASIS_MSRB_30_360; break;
default: default:
case 1: basis = BASIS_30E_360; break; case 1: basis = GO_BASIS_30E_360; break;
case 2: basis = BASIS_MSRB_30_360_SYM; break; case 2: basis = GO_BASIS_MSRB_30_360_SYM; break;
} }
datetime_serial_to_g (&date1, serial1, date_conv); go_date_serial_to_g (&date1, serial1, date_conv);
datetime_serial_to_g (&date2, serial2, date_conv); go_date_serial_to_g (&date2, serial2, date_conv);
if (!g_date_valid (&date1) || !g_date_valid (&date2)) if (!g_date_valid (&date1) || !g_date_valid (&date2))
return value_new_error_VALUE (ei->pos); return value_new_error_VALUE (ei->pos);
return value_new_int (go_datetime_days_between_basis (&date1, &date2, basis)); return value_new_int (go_date_days_between_basis (&date1, &date2, basis));
} }
/***************************************************************************/ /***************************************************************************/
...@@ -718,7 +718,7 @@ gnumeric_eomonth (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -718,7 +718,7 @@ gnumeric_eomonth (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
g_date_get_days_in_month (g_date_get_month (&date), g_date_get_days_in_month (g_date_get_month (&date),
g_date_get_year (&date))); g_date_get_year (&date)));
return make_date (value_new_int (datetime_g_to_serial (&date, conv))); return make_date (value_new_int (go_date_g_to_serial (&date, conv)));
} }
/***************************************************************************/ /***************************************************************************/
...@@ -785,7 +785,7 @@ gnumeric_workday (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -785,7 +785,7 @@ gnumeric_workday (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
hserial = (int)s; hserial = (int)s;
if (j > 0 && hserial == holidays[j - 1]) if (j > 0 && hserial == holidays[j - 1])
continue; /* Dupe */ continue; /* Dupe */
datetime_serial_to_g (&hol, hserial, conv); go_date_serial_to_g (&hol, hserial, conv);
if (!g_date_valid (&hol)) if (!g_date_valid (&hol))
goto bad; goto bad;
if (g_date_get_weekday (&hol) >= G_DATE_SATURDAY) if (g_date_get_weekday (&hol) >= G_DATE_SATURDAY)
...@@ -803,7 +803,7 @@ gnumeric_workday (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -803,7 +803,7 @@ gnumeric_workday (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
idays = (int)days; idays = (int)days;
weekday = g_date_get_weekday (&date); weekday = g_date_get_weekday (&date);
serial = datetime_g_to_serial (&date, conv); serial = go_date_g_to_serial (&date, conv);
if (idays > 0) { if (idays > 0) {
int h = 0; int h = 0;
...@@ -872,13 +872,13 @@ gnumeric_workday (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -872,13 +872,13 @@ gnumeric_workday (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
g_free (holidays); g_free (holidays);
datetime_serial_to_g (&date, serial, conv); go_date_serial_to_g (&date, serial, conv);
if (!g_date_valid (&date) || if (!g_date_valid (&date) ||
g_date_get_year (&date) < 1900 || g_date_get_year (&date) < 1900 ||
g_date_get_year (&date) > 9999) g_date_get_year (&date) > 9999)
return value_new_error_NUM (ei->pos); return value_new_error_NUM (ei->pos);
return make_date (value_new_int (datetime_g_to_serial (&date, conv))); return make_date (value_new_int (go_date_g_to_serial (&date, conv)));
bad: bad:
g_free (holidays); g_free (holidays);
...@@ -910,7 +910,7 @@ get_serial_weekday (int serial, int *offset, GODateConventions const *conv) ...@@ -910,7 +910,7 @@ get_serial_weekday (int serial, int *offset, GODateConventions const *conv)
if (serial <= 0) if (serial <= 0)
return serial; return serial;
datetime_serial_to_g (&date, serial, conv); go_date_serial_to_g (&date, serial, conv);
if (g_date_valid (&date)) { if (g_date_valid (&date)) {
/* Jan 1 1900 was a monday so we won't go < 0 */ /* Jan 1 1900 was a monday so we won't go < 0 */
*offset = (int)g_date_get_weekday (&date) - 1; *offset = (int)g_date_get_weekday (&date) - 1;
...@@ -944,7 +944,7 @@ cb_networkdays_holiday (GnmValueIter const *v_iter, ...@@ -944,7 +944,7 @@ cb_networkdays_holiday (GnmValueIter const *v_iter,
if (serial < cls->start_serial || cls->end_serial < serial) if (serial < cls->start_serial || cls->end_serial < serial)
return NULL; return NULL;
datetime_serial_to_g (&date, serial, conv); go_date_serial_to_g (&date, serial, conv);
if (!g_date_valid (&date)) if (!g_date_valid (&date))
return value_new_error_NUM (v_iter->ep); return value_new_error_NUM (v_iter->ep);
if (g_date_get_weekday (&date) < G_DATE_SATURDAY) if (g_date_get_weekday (&date) < G_DATE_SATURDAY)
...@@ -972,7 +972,7 @@ gnumeric_networkdays (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -972,7 +972,7 @@ gnumeric_networkdays (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
end_serial = tmp; end_serial = tmp;
} }
datetime_serial_to_g (&start_date, start_serial, DATE_CONV (ei->pos)); go_date_serial_to_g (&start_date, start_serial, DATE_CONV (ei->pos));
cls.start_serial = start_serial; cls.start_serial = start_serial;
cls.end_serial = end_serial; cls.end_serial = end_serial;
cls.res = 0; cls.res = 0;
...@@ -1025,7 +1025,7 @@ gnumeric_isoweeknum (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -1025,7 +1025,7 @@ gnumeric_isoweeknum (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
if (!g_date_valid (&date)) if (!g_date_valid (&date))
return value_new_error_VALUE (ei->pos); return value_new_error_VALUE (ei->pos);
return value_new_int (datetime_weeknum (&date, WEEKNUM_METHOD_ISO)); return value_new_int (go_date_weeknum (&date, GO_WEEKNUM_METHOD_ISO));
} }
/***************************************************************************/ /***************************************************************************/
...@@ -1053,7 +1053,7 @@ gnumeric_isoyear (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -1053,7 +1053,7 @@ gnumeric_isoyear (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
if (!g_date_valid (&date)) if (!g_date_valid (&date))
return value_new_error_VALUE (ei->pos); return value_new_error_VALUE (ei->pos);
isoweeknum = datetime_weeknum (&date, WEEKNUM_METHOD_ISO); isoweeknum = go_date_weeknum (&date, GO_WEEKNUM_METHOD_ISO);
year = g_date_get_year (&date); year = g_date_get_year (&date);
month = g_date_get_month (&date); month = g_date_get_month (&date);
if (isoweeknum >= 52 && month == G_DATE_JANUARY) if (isoweeknum >= 52 && month == G_DATE_JANUARY)
...@@ -1086,16 +1086,16 @@ gnumeric_weeknum (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -1086,16 +1086,16 @@ gnumeric_weeknum (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
GDate date; GDate date;
gnm_float method = argv[1] ? gnm_floor (value_get_as_float (argv[1])) : 1; gnm_float method = argv[1] ? gnm_floor (value_get_as_float (argv[1])) : 1;
if (!(method == WEEKNUM_METHOD_SUNDAY || if (!(method == GO_WEEKNUM_METHOD_SUNDAY ||
method == WEEKNUM_METHOD_MONDAY || method == GO_WEEKNUM_METHOD_MONDAY ||
method == WEEKNUM_METHOD_ISO)) method == GO_WEEKNUM_METHOD_ISO))
return value_new_error_VALUE (ei->pos); return value_new_error_VALUE (ei->pos);
datetime_value_to_g (&date, argv[0], DATE_CONV (ei->pos)); datetime_value_to_g (&date, argv[0], DATE_CONV (ei->pos));
if (!g_date_valid (&date)) if (!g_date_valid (&date))
return value_new_error_VALUE (ei->pos); return value_new_error_VALUE (ei->pos);
return value_new_int (datetime_weeknum (&date, (int)method)); return value_new_int (go_date_weeknum (&date, (int)method));
} }
/***************************************************************************/ /***************************************************************************/
...@@ -1117,7 +1117,7 @@ gnumeric_yearfrac (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -1117,7 +1117,7 @@ gnumeric_yearfrac (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{ {
GODateConventions const *conv = DATE_CONV (ei->pos); GODateConventions const *conv = DATE_CONV (ei->pos);
GDate start_date, end_date; GDate start_date, end_date;
int basis = value_get_basis (argv[2], BASIS_MSRB_30_360); int basis = value_get_basis (argv[2], GO_BASIS_MSRB_30_360);
if (basis < 0 || basis > 4 || if (basis < 0 || basis > 4 ||
!datetime_value_to_g (&start_date, argv[0], conv) || !datetime_value_to_g (&start_date, argv[0], conv) ||
......
...@@ -245,7 +245,7 @@ days_monthly_basis (GnmValue const *issue_date, ...@@ -245,7 +245,7 @@ days_monthly_basis (GnmValue const *issue_date,
*/ */
static gnm_float static gnm_float
coupnum (GDate const *settlement, GDate const *maturity, coupnum (GDate const *settlement, GDate const *maturity,
GnmCouponConvention const *conv) GoCouponConvention const *conv)
{ {
int months; int months;
GDate this_coupondate = *maturity; GDate this_coupondate = *maturity;
...@@ -275,25 +275,25 @@ coupnum (GDate const *settlement, GDate const *maturity, ...@@ -275,25 +275,25 @@ coupnum (GDate const *settlement, GDate const *maturity,
static gnm_float static gnm_float
couppcd (GDate const *settlement, GDate const *maturity, couppcd (GDate const *settlement, GDate const *maturity,
GnmCouponConvention const *conv) GoCouponConvention const *conv)
{ {
GDate date; GDate date;
go_coup_cd (&date, settlement, maturity, conv->freq, conv->eom, FALSE); go_coup_cd (&date, settlement, maturity, conv->freq, conv->eom, FALSE);
return datetime_g_to_serial (&date, conv->date_conv); return go_date_g_to_serial (&date, conv->date_conv);
} }
static gnm_float static gnm_float
coupncd (GDate const *settlement, GDate const *maturity, coupncd (GDate const *settlement, GDate const *maturity,
GnmCouponConvention const *conv) GoCouponConvention const *conv)
{ {
GDate date; GDate date;
go_coup_cd (&date, settlement, maturity, conv->freq, conv->eom, TRUE); go_coup_cd (&date, settlement, maturity, conv->freq, conv->eom, TRUE);
return datetime_g_to_serial (&date, conv->date_conv); return go_date_g_to_serial (&date, conv->date_conv);
} }
static gnm_float static gnm_float
price (GDate *settlement, GDate *maturity, gnm_float rate, gnm_float yield, price (GDate *settlement, GDate *maturity, gnm_float rate, gnm_float yield,
gnm_float redemption, GnmCouponConvention const *conv) gnm_float redemption, GoCouponConvention const *conv)
{ {
gnm_float a, d, e, sum, den, basem1, exponent, first_term, last_term; gnm_float a, d, e, sum, den, basem1, exponent, first_term, last_term;
int n; int n;
...@@ -330,13 +330,13 @@ price (GDate *settlement, GDate *maturity, gnm_float rate, gnm_float yield, ...@@ -330,13 +330,13 @@ price (GDate *settlement, GDate *maturity, gnm_float rate, gnm_float yield,
static GnmValue * static GnmValue *
func_coup (GnmFuncEvalInfo *ei, GnmValue const * const *argv, func_coup (GnmFuncEvalInfo *ei, GnmValue const * const *argv,
gnm_float (coup_fn) (GDate const *settle, GDate const *mat, gnm_float (coup_fn) (GDate const *settle, GDate const *mat,
GnmCouponConvention const *conv)) GoCouponConvention const *conv))
{ {
GDate settlement, maturity; GDate settlement, maturity;
GnmCouponConvention conv; GoCouponConvention conv;
conv.freq = value_get_freq (argv[2]); conv.freq = value_get_freq (argv[2]);
conv.basis = value_get_basis (argv[3], BASIS_MSRB_30_360); conv.basis = value_get_basis (argv[3], GO_BASIS_MSRB_30_360);
conv.eom = argv[4] ? value_get_as_checked_bool (argv[4]) : TRUE; conv.eom = argv[4] ? value_get_as_checked_bool (argv[4]) : TRUE;
conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook); conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
...@@ -391,7 +391,7 @@ gnumeric_accrint (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -391,7 +391,7 @@ gnumeric_accrint (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
rate = value_get_as_float (argv[3]); rate = value_get_as_float (argv[3]);
par = value_get_as_float (argv[4]); par = value_get_as_float (argv[4]);
freq = value_get_freq (argv[5]); freq = value_get_freq (argv[5]);
basis = value_get_basis (argv[6], BASIS_MSRB_30_360); basis = value_get_basis (argv[6], GO_BASIS_MSRB_30_360);
if (rate <= 0. || if (rate <= 0. ||
par <= 0. || par <= 0. ||
...@@ -443,7 +443,7 @@ gnumeric_accrintm (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -443,7 +443,7 @@ gnumeric_accrintm (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
rate = value_get_as_float (argv[2]); rate = value_get_as_float (argv[2]);
par = argv[3] ? value_get_as_float (argv[3]) : 1000; par = argv[3] ? value_get_as_float (argv[3]) : 1000;
basis = value_get_basis (argv[4], BASIS_MSRB_30_360); basis = value_get_basis (argv[4], GO_BASIS_MSRB_30_360);
a = days_monthly_basis (argv[0], argv[1], basis, date_conv); a = days_monthly_basis (argv[0], argv[1], basis, date_conv);
d = annual_year_basis (argv[0], basis, date_conv); d = annual_year_basis (argv[0], basis, date_conv);
...@@ -481,7 +481,7 @@ gnumeric_intrate (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -481,7 +481,7 @@ gnumeric_intrate (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
investment = value_get_as_float (argv[2]); investment = value_get_as_float (argv[2]);
redemption = value_get_as_float (argv[3]); redemption = value_get_as_float (argv[3]);
basis = value_get_basis (argv[4], BASIS_MSRB_30_360); basis = value_get_basis (argv[4], GO_BASIS_MSRB_30_360);
a = days_monthly_basis (argv[0], argv[1], basis, date_conv); a = days_monthly_basis (argv[0], argv[1], basis, date_conv);
d = annual_year_basis (argv[0], basis, date_conv); d = annual_year_basis (argv[0], basis, date_conv);
...@@ -519,7 +519,7 @@ gnumeric_received (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -519,7 +519,7 @@ gnumeric_received (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
investment = value_get_as_float (argv[2]); investment = value_get_as_float (argv[2]);
discount = value_get_as_float (argv[3]); discount = value_get_as_float (argv[3]);
basis = value_get_basis (argv[4], BASIS_MSRB_30_360); basis = value_get_basis (argv[4], GO_BASIS_MSRB_30_360);
a = days_monthly_basis (argv[0], argv[1], basis, date_conv); a = days_monthly_basis (argv[0], argv[1], basis, date_conv);
d = annual_year_basis (argv[0], basis, date_conv); d = annual_year_basis (argv[0], basis, date_conv);
...@@ -559,7 +559,7 @@ gnumeric_pricedisc (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -559,7 +559,7 @@ gnumeric_pricedisc (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
discount = value_get_as_float (argv[2]); discount = value_get_as_float (argv[2]);
redemption = value_get_as_float (argv[3]); redemption = value_get_as_float (argv[3]);
basis = value_get_basis (argv[4], BASIS_MSRB_30_360); basis = value_get_basis (argv[4], GO_BASIS_MSRB_30_360);
a = days_monthly_basis (argv[0], argv[1], basis, date_conv); a = days_monthly_basis (argv[0], argv[1], basis, date_conv);
d = annual_year_basis (argv[0], basis, date_conv); d = annual_year_basis (argv[0], basis, date_conv);
...@@ -596,7 +596,7 @@ gnumeric_pricemat (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -596,7 +596,7 @@ gnumeric_pricemat (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
discount = value_get_as_float (argv[3]); discount = value_get_as_float (argv[3]);
yield = value_get_as_float (argv[4]); yield = value_get_as_float (argv[4]);
basis = value_get_basis (argv[5], BASIS_MSRB_30_360); basis = value_get_basis (argv[5], GO_BASIS_MSRB_30_360);
dsm = days_monthly_basis (argv[0], argv[1], basis, date_conv); dsm = days_monthly_basis (argv[0], argv[1], basis, date_conv);
dim = days_monthly_basis (argv[2], argv[1], basis, date_conv); dim = days_monthly_basis (argv[2], argv[1], basis, date_conv);
...@@ -641,7 +641,7 @@ gnumeric_disc (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -641,7 +641,7 @@ gnumeric_disc (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
par = value_get_as_float (argv[2]); par = value_get_as_float (argv[2]);
redemption = value_get_as_float (argv[3]); redemption = value_get_as_float (argv[3]);
basis = value_get_basis (argv[4], BASIS_MSRB_30_360); basis = value_get_basis (argv[4], GO_BASIS_MSRB_30_360);
b = annual_year_basis (argv[0], basis, date_conv); b = annual_year_basis (argv[0], basis, date_conv);
dsm = days_monthly_basis (argv[0], argv[1], basis, date_conv); dsm = days_monthly_basis (argv[0], argv[1], basis, date_conv);
...@@ -1846,7 +1846,7 @@ gnumeric_duration (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -1846,7 +1846,7 @@ gnumeric_duration (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
GDate nSettle, nMat; GDate nSettle, nMat;
gnm_float fCoup, fYield; gnm_float fCoup, fYield;
gnm_float fNumOfCoups; gnm_float fNumOfCoups;
GnmCouponConvention conv; GoCouponConvention conv;
conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook); conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
conv.eom = TRUE; conv.eom = TRUE;
...@@ -1854,7 +1854,7 @@ gnumeric_duration (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -1854,7 +1854,7 @@ gnumeric_duration (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
fCoup = value_get_as_float (argv[2]); fCoup = value_get_as_float (argv[2]);
fYield = value_get_as_float (argv[3]); fYield = value_get_as_float (argv[3]);
conv.freq = value_get_freq (argv[4]); conv.freq = value_get_freq (argv[4]);
conv.basis = value_get_basis (argv[5], BASIS_MSRB_30_360); conv.basis = value_get_basis (argv[5], GO_BASIS_MSRB_30_360);
if (!datetime_value_to_g (&nSettle, argv[0], conv.date_conv) || if (!datetime_value_to_g (&nSettle, argv[0], conv.date_conv) ||
!datetime_value_to_g (&nMat, argv[1], conv.date_conv) || !datetime_value_to_g (&nMat, argv[1], conv.date_conv) ||
...@@ -2085,7 +2085,7 @@ gnumeric_price (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -2085,7 +2085,7 @@ gnumeric_price (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{ {
GDate settlement, maturity; GDate settlement, maturity;
gnm_float rate, yield, redemption; gnm_float rate, yield, redemption;
GnmCouponConvention conv; GoCouponConvention conv;
conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook); conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
...@@ -2094,7 +2094,7 @@ gnumeric_price (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -2094,7 +2094,7 @@ gnumeric_price (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
redemption = value_get_as_float (argv[4]); redemption = value_get_as_float (argv[4]);
conv.freq = value_get_freq (argv[5]); conv.freq = value_get_freq (argv[5]);
conv.eom = TRUE; conv.eom = TRUE;
conv.basis = value_get_basis (argv[6], BASIS_MSRB_30_360); conv.basis = value_get_basis (argv[6], GO_BASIS_MSRB_30_360);
if (!datetime_value_to_g (&settlement, argv[0], conv.date_conv) || if (!datetime_value_to_g (&settlement, argv[0], conv.date_conv) ||
!datetime_value_to_g (&maturity, argv[1], conv.date_conv)) !datetime_value_to_g (&maturity, argv[1], conv.date_conv))
...@@ -2133,7 +2133,7 @@ static GnmFuncHelp const help_yield[] = { ...@@ -2133,7 +2133,7 @@ static GnmFuncHelp const help_yield[] = {
typedef struct { typedef struct {
GDate settlement, maturity; GDate settlement, maturity;
gnm_float rate, redemption, par; gnm_float rate, redemption, par;
GnmCouponConvention conv; GoCouponConvention conv;
} gnumeric_yield_t; } gnumeric_yield_t;
static GoalSeekStatus static GoalSeekStatus
...@@ -2158,7 +2158,7 @@ gnumeric_yield (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -2158,7 +2158,7 @@ gnumeric_yield (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
udata.par = value_get_as_float (argv[3]); udata.par = value_get_as_float (argv[3]);
udata.redemption = value_get_as_float (argv[4]); udata.redemption = value_get_as_float (argv[4]);
udata.conv.freq = value_get_freq (argv[5]); udata.conv.freq = value_get_freq (argv[5]);
udata.conv.basis = value_get_basis (argv[6], BASIS_MSRB_30_360); udata.conv.basis = value_get_basis (argv[6], GO_BASIS_MSRB_30_360);
udata.conv.eom = TRUE; udata.conv.eom = TRUE;
udata.conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook); udata.conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
...@@ -2248,7 +2248,7 @@ gnumeric_yielddisc (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -2248,7 +2248,7 @@ gnumeric_yielddisc (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
fPrice = value_get_as_float (argv[2]); fPrice = value_get_as_float (argv[2]);
fRedemp = value_get_as_float (argv[3]); fRedemp = value_get_as_float (argv[3]);
basis = value_get_basis (argv[4], BASIS_MSRB_30_360); basis = value_get_basis (argv[4], GO_BASIS_MSRB_30_360);
if (!is_valid_basis (basis) || if (!is_valid_basis (basis) ||
!datetime_value_to_g (&settlement, argv[0], date_conv) || !datetime_value_to_g (&settlement, argv[0], date_conv) ||
...@@ -2293,7 +2293,7 @@ gnumeric_yieldmat (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -2293,7 +2293,7 @@ gnumeric_yieldmat (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
fRate = value_get_as_float (argv[3]); fRate = value_get_as_float (argv[3]);
fPrice = value_get_as_float (argv[4]); fPrice = value_get_as_float (argv[4]);
basis = value_get_basis (argv[5], BASIS_MSRB_30_360); basis = value_get_basis (argv[5], GO_BASIS_MSRB_30_360);
if (!is_valid_basis (basis) || if (!is_valid_basis (basis) ||
fRate < 0 || fRate < 0 ||
...@@ -2327,7 +2327,7 @@ static GnmFuncHelp const help_oddfprice[] = { ...@@ -2327,7 +2327,7 @@ static GnmFuncHelp const help_oddfprice[] = {