/* Assumes there is always at least 32 characters available in the target buffer */ int fpconv_g_fmt(char *str, double num, int precision) { char buf[FPCONV_G_FMT_BUFSIZE]; char fmt[6]; int len; char *b; set_number_format(fmt, precision); /* Pass through when decimal point character is dot. */ if (locale_decimal_point == '.') //return snprintf(str, FPCONV_G_FMT_BUFSIZE, fmt, num); return sprintf(str, fmt, num); /* snprintf() to a buffer then translate for other decimal point characters */ //len = snprintf(buf, FPCONV_G_FMT_BUFSIZE, fmt, num); len = sprintf(buf, fmt, num); /* Copy into target location. Translate decimal point if required */ b = buf; do { *str++ = (*b == locale_decimal_point ? '.' : *b); } while(*b++); return len; }
XLNT_FUNCTION void cell::set_value(timedelta t) { d_->type_ = type::numeric; d_->value_numeric_ = t.to_number(); set_number_format(number_format::date_timedelta()); }
XLNT_FUNCTION void cell::set_value(datetime d) { d_->type_ = type::numeric; d_->value_numeric_ = d.to_number(get_base_date()); set_number_format(number_format::date_datetime()); }