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)
g_date_clear (&date, 1);
g_date_set_dmy (&date, d, mo, y);
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));
v = value_new_float (d_serial + h/24. + mi/(24.*60.) + s/(24.*60.*60.));
} else
......
......@@ -147,7 +147,7 @@ xls_read_pivot_cache_value (XLSReadPivot *s, BiffQuery *q)
g_date_set_dmy (&date, d, m, y);
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));
double time_frac = h + ((double)mi / 60.) + ((double)se / 3600.);
GnmValue *res = value_new_float (d_serial + time_frac / 24.);
......
......@@ -546,7 +546,7 @@ attr_datetime (GsfXMLIn *xin, xmlChar const **attrs,
g_date_set_dmy (&date, d, m, y);
if (g_date_valid (&date)) {
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));
if (n >= 6) {
double time_frac = h + ((double)mi / 60.) + ((double)s / 3600.);
......
......@@ -121,7 +121,7 @@ gnumeric_date (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
g_date_get_year (&date) >= 11900)
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:
return value_new_error_NUM (ei->pos);
......@@ -149,7 +149,7 @@ gnumeric_unix2date (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
if (gnm_abs (futime - utime) >= 1.0)
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)
return value_new_error_VALUE (ei->pos);
......@@ -173,7 +173,7 @@ gnumeric_date2unix (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
gnm_float fserial = value_get_as_float (argv [0]);
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. */
if (gnm_abs (fserial - serial) >= 1.0 || utime == (time_t)-1)
......@@ -226,7 +226,7 @@ datedif_opt_ym (GDate *gdate1, GDate *gdate2)
g_assert (g_date_valid (gdate1));
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
......@@ -240,7 +240,7 @@ datedif_opt_yd (GDate *gdate1, GDate *gdate2, int excel_compat)
day = g_date_get_day (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 */
if (excel_compat) {
......@@ -279,7 +279,7 @@ datedif_opt_md (GDate *gdate1, GDate *gdate2, gboolean excel_compat)
day = g_date_get_day (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 */
if (excel_compat) {
......@@ -322,15 +322,15 @@ gnumeric_datedif (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
if (!strcmp (opt, "d"))
return value_new_int (date2 - date1);
datetime_serial_to_g (&d1, date1, conv);
datetime_serial_to_g (&d2, date2, conv);
go_date_serial_to_g (&d1, date1, conv);
go_date_serial_to_g (&d2, date2, conv);
if (!g_date_valid (&d1) || !g_date_valid (&d2))
return value_new_error_VALUE (ei->pos);
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"))
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"))
return value_new_int (datedif_opt_ym (&d1, &d2));
else if (!strcmp (opt, "yd"))
......@@ -367,7 +367,7 @@ gnumeric_edate (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
if (months > INT_MAX / 2 || -months > INT_MAX / 2)
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);
if (!g_date_valid (&date) ||
......@@ -375,7 +375,7 @@ gnumeric_edate (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
g_date_get_year (&date) > 9999)
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[] = {
static GnmValue *
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[] = {
static GnmValue *
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[] = {
static GnmValue *
gnumeric_days360 (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
basis_t basis;
go_basis_t basis;
GDate date1, date2;
GODateConventions const *date_conv = DATE_CONV (ei->pos);
gnm_float serial1 = datetime_value_to_serial (argv[0], date_conv);
......@@ -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;
switch ((int)method) {
case 0: basis = BASIS_MSRB_30_360; break;
case 0: basis = GO_BASIS_MSRB_30_360; break;
default:
case 1: basis = BASIS_30E_360; break;
case 2: basis = BASIS_MSRB_30_360_SYM; break;
case 1: basis = GO_BASIS_30E_360; break;
case 2: basis = GO_BASIS_MSRB_30_360_SYM; break;
}
datetime_serial_to_g (&date1, serial1, date_conv);
datetime_serial_to_g (&date2, serial2, date_conv);
go_date_serial_to_g (&date1, serial1, date_conv);
go_date_serial_to_g (&date2, serial2, date_conv);
if (!g_date_valid (&date1) || !g_date_valid (&date2))
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)
g_date_get_days_in_month (g_date_get_month (&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)
hserial = (int)s;
if (j > 0 && hserial == holidays[j - 1])
continue; /* Dupe */
datetime_serial_to_g (&hol, hserial, conv);
go_date_serial_to_g (&hol, hserial, conv);
if (!g_date_valid (&hol))
goto bad;
if (g_date_get_weekday (&hol) >= G_DATE_SATURDAY)
......@@ -803,7 +803,7 @@ gnumeric_workday (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
idays = (int)days;
weekday = g_date_get_weekday (&date);
serial = datetime_g_to_serial (&date, conv);
serial = go_date_g_to_serial (&date, conv);
if (idays > 0) {
int h = 0;
......@@ -872,13 +872,13 @@ gnumeric_workday (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
g_free (holidays);
datetime_serial_to_g (&date, serial, conv);
go_date_serial_to_g (&date, serial, conv);
if (!g_date_valid (&date) ||
g_date_get_year (&date) < 1900 ||
g_date_get_year (&date) > 9999)
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:
g_free (holidays);
......@@ -910,7 +910,7 @@ get_serial_weekday (int serial, int *offset, GODateConventions const *conv)
if (serial <= 0)
return serial;
datetime_serial_to_g (&date, serial, conv);
go_date_serial_to_g (&date, serial, conv);
if (g_date_valid (&date)) {
/* Jan 1 1900 was a monday so we won't go < 0 */
*offset = (int)g_date_get_weekday (&date) - 1;
......@@ -944,7 +944,7 @@ cb_networkdays_holiday (GnmValueIter const *v_iter,
if (serial < cls->start_serial || cls->end_serial < serial)
return NULL;
datetime_serial_to_g (&date, serial, conv);
go_date_serial_to_g (&date, serial, conv);
if (!g_date_valid (&date))
return value_new_error_NUM (v_iter->ep);
if (g_date_get_weekday (&date) < G_DATE_SATURDAY)
......@@ -972,7 +972,7 @@ gnumeric_networkdays (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
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.end_serial = end_serial;
cls.res = 0;
......@@ -1025,7 +1025,7 @@ gnumeric_isoweeknum (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
if (!g_date_valid (&date))
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)
if (!g_date_valid (&date))
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);
month = g_date_get_month (&date);
if (isoweeknum >= 52 && month == G_DATE_JANUARY)
......@@ -1086,16 +1086,16 @@ gnumeric_weeknum (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
GDate date;
gnm_float method = argv[1] ? gnm_floor (value_get_as_float (argv[1])) : 1;
if (!(method == WEEKNUM_METHOD_SUNDAY ||
method == WEEKNUM_METHOD_MONDAY ||
method == WEEKNUM_METHOD_ISO))
if (!(method == GO_WEEKNUM_METHOD_SUNDAY ||
method == GO_WEEKNUM_METHOD_MONDAY ||
method == GO_WEEKNUM_METHOD_ISO))
return value_new_error_VALUE (ei->pos);
datetime_value_to_g (&date, argv[0], DATE_CONV (ei->pos));
if (!g_date_valid (&date))
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)
{
GODateConventions const *conv = DATE_CONV (ei->pos);
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 ||
!datetime_value_to_g (&start_date, argv[0], conv) ||
......
......@@ -245,7 +245,7 @@ days_monthly_basis (GnmValue const *issue_date,
*/
static gnm_float
coupnum (GDate const *settlement, GDate const *maturity,
GnmCouponConvention const *conv)
GoCouponConvention const *conv)
{
int months;
GDate this_coupondate = *maturity;
......@@ -275,25 +275,25 @@ coupnum (GDate const *settlement, GDate const *maturity,
static gnm_float
couppcd (GDate const *settlement, GDate const *maturity,
GnmCouponConvention const *conv)
GoCouponConvention const *conv)
{
GDate date;
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
coupncd (GDate const *settlement, GDate const *maturity,
GnmCouponConvention const *conv)
GoCouponConvention const *conv)
{
GDate date;
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
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;
int n;
......@@ -330,13 +330,13 @@ price (GDate *settlement, GDate *maturity, gnm_float rate, gnm_float yield,
static GnmValue *
func_coup (GnmFuncEvalInfo *ei, GnmValue const * const *argv,
gnm_float (coup_fn) (GDate const *settle, GDate const *mat,
GnmCouponConvention const *conv))
GoCouponConvention const *conv))
{
GDate settlement, maturity;
GnmCouponConvention conv;
GoCouponConvention conv;
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.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
......@@ -391,7 +391,7 @@ gnumeric_accrint (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
rate = value_get_as_float (argv[3]);
par = value_get_as_float (argv[4]);
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. ||
par <= 0. ||
......@@ -443,7 +443,7 @@ gnumeric_accrintm (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
rate = value_get_as_float (argv[2]);
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);
d = annual_year_basis (argv[0], basis, date_conv);
......@@ -481,7 +481,7 @@ gnumeric_intrate (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
investment = value_get_as_float (argv[2]);
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);
d = annual_year_basis (argv[0], basis, date_conv);
......@@ -519,7 +519,7 @@ gnumeric_received (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
investment = value_get_as_float (argv[2]);
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);
d = annual_year_basis (argv[0], basis, date_conv);
......@@ -559,7 +559,7 @@ gnumeric_pricedisc (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
discount = value_get_as_float (argv[2]);
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);
d = annual_year_basis (argv[0], basis, date_conv);
......@@ -596,7 +596,7 @@ gnumeric_pricemat (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
discount = value_get_as_float (argv[3]);
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);
dim = days_monthly_basis (argv[2], argv[1], basis, date_conv);
......@@ -641,7 +641,7 @@ gnumeric_disc (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
par = value_get_as_float (argv[2]);
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);
dsm = days_monthly_basis (argv[0], argv[1], basis, date_conv);
......@@ -1846,7 +1846,7 @@ gnumeric_duration (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
GDate nSettle, nMat;
gnm_float fCoup, fYield;
gnm_float fNumOfCoups;
GnmCouponConvention conv;
GoCouponConvention conv;
conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
conv.eom = TRUE;
......@@ -1854,7 +1854,7 @@ gnumeric_duration (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
fCoup = value_get_as_float (argv[2]);
fYield = value_get_as_float (argv[3]);
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) ||
!datetime_value_to_g (&nMat, argv[1], conv.date_conv) ||
......@@ -2085,7 +2085,7 @@ gnumeric_price (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
GDate settlement, maturity;
gnm_float rate, yield, redemption;
GnmCouponConvention conv;
GoCouponConvention conv;
conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
......@@ -2094,7 +2094,7 @@ gnumeric_price (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
redemption = value_get_as_float (argv[4]);
conv.freq = value_get_freq (argv[5]);
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) ||
!datetime_value_to_g (&maturity, argv[1], conv.date_conv))
......@@ -2133,7 +2133,7 @@ static GnmFuncHelp const help_yield[] = {
typedef struct {
GDate settlement, maturity;
gnm_float rate, redemption, par;
GnmCouponConvention conv;
GoCouponConvention conv;
} gnumeric_yield_t;
static GoalSeekStatus
......@@ -2158,7 +2158,7 @@ gnumeric_yield (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
udata.par = value_get_as_float (argv[3]);
udata.redemption = value_get_as_float (argv[4]);
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.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
......@@ -2248,7 +2248,7 @@ gnumeric_yielddisc (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
fPrice = value_get_as_float (argv[2]);
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) ||
!datetime_value_to_g (&settlement, argv[0], date_conv) ||
......@@ -2293,7 +2293,7 @@ gnumeric_yieldmat (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
fRate = value_get_as_float (argv[3]);
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) ||
fRate < 0 ||
......@@ -2327,7 +2327,7 @@ static GnmFuncHelp const help_oddfprice[] = {
static gnm_float
date_ratio (GDate const *d1, const GDate *d2, const GDate *d3,
GnmCouponConvention const *conv)
GoCouponConvention const *conv)
{
GDate next_coupon, prev_coupon;
gnm_float res;
......@@ -2342,10 +2342,10 @@ date_ratio (GDate const *d1, const GDate *d2, const GDate *d3,
return gnm_nan;
if (g_date_compare (&next_coupon, d2) >= 0)
return go_datetime_days_between_basis (d1, d2, conv->basis) /
return go_date_days_between_basis (d1, d2, conv->basis) /
go_coupdays (&prev_coupon, &next_coupon, conv);
res = go_datetime_days_between_basis (d1, &next_coupon, conv->basis) /
res = go_date_days_between_basis (d1, &next_coupon, conv->basis) /
go_coupdays (&prev_coupon, &next_coupon, conv);
while (1) {
prev_coupon = next_coupon;
......@@ -2353,7 +2353,7 @@ date_ratio (GDate const *d1, const GDate *d2, const GDate *d3,
if (!g_date_valid (&next_coupon))
return gnm_nan;
if (g_date_compare (&next_coupon, d2) >= 0) {
res += go_datetime_days_between_basis (&prev_coupon, d2, conv->basis) /
res += go_date_days_between_basis (&prev_coupon, d2, conv->basis) /
go_coupdays (&prev_coupon, &next_coupon, conv);
return res;
}
......@@ -2365,12 +2365,12 @@ static gnm_float
calc_oddfprice (const GDate *settlement, const GDate *maturity,
const GDate *issue, const GDate *first_coupon,
gnm_float rate, gnm_float yield, gnm_float redemption,
GnmCouponConvention const *conv)
GoCouponConvention const *conv)
{
gnm_float a = go_datetime_days_between_basis (issue, settlement, conv->basis);
gnm_float ds = go_datetime_days_between_basis (settlement, first_coupon, conv->basis);
gnm_float df = go_datetime_days_between_basis (issue, first_coupon, conv->basis);
gnm_float a = go_date_days_between_basis (issue, settlement, conv->basis);
gnm_float ds = go_date_days_between_basis (settlement, first_coupon, conv->basis);
gnm_float df = go_date_days_between_basis (issue, first_coupon, conv->basis);
gnm_float e = go_coupdays (settlement, maturity, conv);
int n = (int)coupnum (settlement, maturity, conv);
gnm_float scale = 100.0 * rate / conv->freq;
......@@ -2380,9 +2380,9 @@ calc_oddfprice (const GDate *settlement, const GDate *maturity,
if (ds > e) {
/* Odd-long corrections. */
switch (conv->basis) {
case BASIS_MSRB_30_360:
case BASIS_30E_360: {
int cdays = go_datetime_days_between_basis (first_coupon, maturity, conv->basis);
case GO_BASIS_MSRB_30_360:
case GO_BASIS_30E_360: {
int cdays = go_date_days_between_basis (first_coupon, maturity, conv->basis);
n = 1 + (int)gnm_ceil (cdays / e);
break;
}
......@@ -2394,7 +2394,7 @@ calc_oddfprice (const GDate *settlement, const GDate *maturity,
GDate prev_date = d;
gnm_date_add_months (&d, 12 / conv->freq);
if (g_date_compare (&d, maturity) >= 0) {
n += (int)gnm_ceil (go_datetime_days_between_basis (&prev_date, maturity, conv->basis) /
n += (int)gnm_ceil (go_date_days_between_basis (&prev_date, maturity, conv->basis) /
go_coupdays (&prev_date, &d, conv))
+ 1;
break;
......@@ -2422,7 +2422,7 @@ gnumeric_oddfprice (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
GDate settlement, maturity, issue, first_coupon;
gnm_float rate, yield, redemption;
GnmCouponConvention conv;
GoCouponConvention conv;
rate = value_get_as_float (argv[4]);
yield = value_get_as_float (argv[5]);
......@@ -2430,7 +2430,7 @@ gnumeric_oddfprice (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
conv.eom = TRUE;
conv.freq = value_get_freq (argv[7]);
conv.basis = value_get_basis (argv[8], BASIS_MSRB_30_360);
conv.basis = value_get_basis (argv[8], GO_BASIS_MSRB_30_360);
conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
if (!datetime_value_to_g (&settlement, argv[0], conv.date_conv) ||
......@@ -2478,7 +2478,7 @@ static GnmFuncHelp const help_oddfyield[] = {
struct gnumeric_oddyield_f {
GDate settlement, maturity, issue, first_coupon;
gnm_float rate, price, redemption;
GnmCouponConvention conv;
GoCouponConvention conv;
};
static GoalSeekStatus
......@@ -2508,7 +2508,7 @@ gnumeric_oddfyield (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
udata.conv.eom = TRUE;
udata.conv.freq = value_get_freq (argv[7]);
udata.conv.basis = value_get_basis (argv[8], BASIS_MSRB_30_360);
udata.conv.basis = value_get_basis (argv[8], GO_BASIS_MSRB_30_360);
udata.conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
if (!datetime_value_to_g (&udata.settlement, argv[0], udata.conv.date_conv) ||
......@@ -2574,7 +2574,7 @@ static gnm_float
calc_oddlprice (const GDate *settlement, const GDate *maturity,
const GDate *last_interest,
gnm_float rate, gnm_float yield, gnm_float redemption,
GnmCouponConvention *conv)
GoCouponConvention *conv)
{
GDate d = *last_interest;
gnm_float x1, x2, x3;
......@@ -2598,7 +2598,7 @@ gnumeric_oddlprice (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
GDate settlement, maturity, last_interest;
gnm_float rate, yield, redemption;
GnmCouponConvention conv;
GoCouponConvention conv;
rate = value_get_as_float (argv[3]);
yield = value_get_as_float (argv[4]);
......@@ -2606,7 +2606,7 @@ gnumeric_oddlprice (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
conv.eom = TRUE;
conv.freq = value_get_freq (argv[6]);
conv.basis = value_get_basis (argv[7], BASIS_MSRB_30_360);
conv.basis = value_get_basis (argv[7], GO_BASIS_MSRB_30_360);
conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
if (!datetime_value_to_g (&settlement, argv[0], conv.date_conv) ||
......@@ -2653,7 +2653,7 @@ static gnm_float
calc_oddlyield (GDate const *settlement, GDate const *maturity,
GDate const *last_interest,
gnm_float rate, gnm_float price, gnm_float redemption,
GnmCouponConvention const *conv)
GoCouponConvention const *conv)
{
GDate d = *last_interest;
gnm_float x1, x2, x3;
......@@ -2676,7 +2676,7 @@ gnumeric_oddlyield (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
GDate settlement, maturity, last_interest;
gnm_float rate, price, redemption;
GnmCouponConvention conv;
GoCouponConvention conv;
rate = value_get_as_float (argv[3]);
price = value_get_as_float (argv[4]);
......@@ -2684,7 +2684,7 @@ gnumeric_oddlyield (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
conv.eom = TRUE;
conv.freq = value_get_freq (argv[6]);
conv.basis = value_get_basis (argv[7], BASIS_MSRB_30_360);
conv.basis = value_get_basis (argv[7], GO_BASIS_MSRB_30_360);
conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
if (!datetime_value_to_g (&settlement, argv[0], conv.date_conv) ||
......@@ -2743,7 +2743,7 @@ gnumeric_amordegrc (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
fRestVal = value_get_as_float (argv[3]);
nPer = value_get_as_int (argv[4]);
fRate = value_get_as_float (argv[5]);
basis = value_get_basis (argv[6], BASIS_MSRB_30_360);
basis = value_get_basis (argv[6], GO_BASIS_MSRB_30_360);
if (!is_valid_basis (basis) ||
fRate < 0 ||
......@@ -2789,7 +2789,7 @@ gnumeric_amorlinc (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
fRestVal = value_get_as_float (argv[3]);
nPer = value_get_as_int (argv[4]);
fRate = value_get_as_float (argv[5]);
basis = value_get_basis (argv[6], BASIS_MSRB_30_360);
basis = value_get_basis (argv[6], GO_BASIS_MSRB_30_360);
if (!is_valid_basis (basis) ||
fRate < 0 ||
......@@ -3060,7 +3060,7 @@ gnumeric_mduration (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
GDate nSettle, nMat;
gnm_float fCoup, fYield;
gnm_float fNumOfCoups;
GnmCouponConvention conv;
GoCouponConvention conv;
conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
conv.eom = TRUE;
......@@ -3068,7 +3068,7 @@ gnumeric_mduration (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
fCoup = value_get_as_float (argv[2]);
fYield = value_get_as_float (argv[3]);
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);
conv.eom = FALSE;
if (!is_valid_basis (conv.basis) ||
......
......@@ -62,7 +62,7 @@ gnm_value_new_from_gda (GValue const *gval,
if (t == GDA_TYPE_USHORT)
return value_new_int (gda_value_get_ushort (gval));
if (t == G_TYPE_DATE) {
res = value_new_int (datetime_g_to_serial (
res = value_new_int (go_date_g_to_serial (
(GDate const *) g_value_get_boxed (gval), date_conv));
value_set_fmt (res, go_format_default_date ());
return res;
......
......@@ -1215,7 +1215,7 @@ oo_cell_start (GsfXMLIn *xin, xmlChar const **attrs)
GDate date;
g_date_set_dmy (&date, d, m, y);
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->pos.wb));
if (n >= 6) {
double time_frac = h + ((double)mi / 60.) + ((double)s / 3600.);
......
......@@ -187,7 +187,7 @@ paradox_file_open (GOFileOpener const *fo, GOIOContext *io_context,
if (0 < PX_get_data_long (pxdoc, &data[offset], pxf->px_flen, &value)) {
PX_SdnToGregorian (value+1721425, &year, &month, &day);
date = g_date_new_dmy (day, month, year);
val = value_new_int (datetime_g_to_serial (date, NULL));
val = value_new_int (go_date_g_to_serial (date, NULL));
value_set_fmt (val, go_format_default_date ());
g_date_free (date);
}
......
......@@ -93,7 +93,7 @@ xbase_field_as_value (gchar *content, XBfield *field, XBfile *file)
g_date_valid_dmy (day, month, year)) {
GDate *date = g_date_new_dmy (day, month, year);
/* Use default date convention */
val = value_new_int (datetime_g_to_serial (date, NULL));
val = value_new_int (go_date_g_to_serial (date, NULL));
g_date_free (date);
} else
val = value_new_string (s);
......
......@@ -89,7 +89,7 @@ datetime_value_to_serial (GnmValue const *v, GODateConventions const *conv)
double serial = datetime_value_to_serial_raw (v, conv);
if (serial >= G_MAXINT || serial < G_MININT)
return G_MAXINT;
return datetime_serial_raw_to_serial (serial);
return go_date_serial_raw_to_serial (serial);
}
/* ------------------------------------------------------------------------- */
......@@ -102,7 +102,7 @@ datetime_value_to_g (GDate *res, GnmValue const *v, GODateConventions const *con
g_date_clear (res, 1);
return FALSE;
}
datetime_serial_to_g (res, serial, conv);
go_date_serial_to_g (res, serial, conv);
return g_date_valid (res);
}
......@@ -125,24 +125,24 @@ datetime_value_to_g (GDate *res, GnmValue const *v, GODateConventions const *con
* year).