Datum ora_timestamp_round(PG_FUNCTION_ARGS) { Timestamp timestamp = PG_GETARG_TIMESTAMP(0); Timestamp result; text *fmt = PG_GETARG_TEXT_PP(1); fsec_t fsec; struct pg_tm tt, *tm = &tt; bool redotz = false; if (TIMESTAMP_NOT_FINITE(timestamp)) PG_RETURN_TIMESTAMPTZ(timestamp); if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL, NULL) != 0) ereport(ERROR, (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), errmsg("timestamp out of range"))); tm_round(tm, fmt, &redotz); if (tm2timestamp(tm, fsec, NULL, &result) != 0) ereport(ERROR, (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), errmsg("timestamp out of range"))); PG_RETURN_TIMESTAMP(result); }
Datum ora_timestamptz_round(PG_FUNCTION_ARGS) { TimestampTz timestamp = PG_GETARG_TIMESTAMPTZ(0); TimestampTz result; text *fmt = PG_GETARG_TEXT_PP(1); int tz; fsec_t fsec; struct pg_tm tt, *tm = &tt; const char *tzn; bool redotz = false; if (TIMESTAMP_NOT_FINITE(timestamp)) PG_RETURN_TIMESTAMPTZ(timestamp); if (timestamp2tm(timestamp, &tz, tm, &fsec, &tzn, NULL) != 0) ereport(ERROR, (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), errmsg("timestamp out of range"))); tm_round(tm, fmt, &redotz); if (redotz) tz = DetermineTimeZoneOffset(tm, get_session_timezone(fcinfo)); if (tm2timestamp(tm, fsec, &tz, &result) != 0) ereport(ERROR, (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), errmsg("timestamp out of range"))); PG_RETURN_TIMESTAMPTZ(result); }
int smart_font_rep::adjusted_dpi (string fam, string var, string ser, string sh, int attempt) { int ex1= get_ex (mfam, variant, series, rshape, 1); int ex2= get_ex (fam, var, ser, sh, attempt); double zoom= 1.0; if (ex1 != 0 && ex2 != 0) zoom= ((double) ex1) / ((double) ex2); if (zoom > 0.975 && zoom < 1.025) zoom= 1; //cout << mfam << ", " << fam << " -> " // << ex1 << ", " << ex2 << ", " << zoom << "\n"; return (int) tm_round (dpi * zoom); }
void math_font_rep::init_font (int fn_nr, font& fn) { tree t= font_name [fn_nr]; if (is_tuple (t, "virtual", 3)) fn= virtual_font (this, as_string (t[1]), as_int (t[2]), (int) tm_round (as_int (t[3]) * zf)); else fn= find_magnified_font (t, zf); ASSERT (!is_nil (fn), "font not found"); fn->copy_math_pars (base_fn); font_table [fn_nr]= fn; }
box text_box_rep::adjust_kerning (int mode, double factor) { if (N(str) == 0) return this; SI pad= (SI) tm_round ((factor * fn->wfn) / 2); xkerning nxk (pad, 0, 0); if (!is_nil (xk) && (mode & PROTRUSION_MASK) == 0) { nxk->left = xk->left; nxk->right= xk->right; } if ((mode & PROTRUSION_MASK) != 0) { nxk->left = -fn->get_left_protrusion (str, mode); nxk->right= -fn->get_right_protrusion (str, mode); } if ((mode & START_OF_LINE) != 0) nxk->left -= pad; if ((mode & END_OF_LINE ) != 0) nxk->right -= pad; return tm_new<text_box_rep> (ip, pos, str, fn, pen, nxk); }
font smart_font_rep::magnify (double zoom) { return smart_font (family, variant, series, shape, sz, (int) tm_round (dpi * zoom)); }