Commit a4127498 authored by Tom Lane's avatar Tom Lane

Replace overly-cute coding with code that (a) has defined behavior

according to the ANSI C spec, (b) gets the boundary conditions right,
and (c) is about a third as long and three times more intelligible.
parent 90f42847
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
* formatting.c * formatting.c
* *
* $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.27 2000/12/15 19:15:09 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.28 2000/12/23 04:05:31 tgl Exp $
* *
* *
* Portions Copyright (c) 1999-2000, PostgreSQL, Inc * Portions Copyright (c) 1999-2000, PostgreSQL, Inc
...@@ -2775,15 +2775,13 @@ to_timestamp(PG_FUNCTION_ARGS) ...@@ -2775,15 +2775,13 @@ to_timestamp(PG_FUNCTION_ARGS)
#endif #endif
if (tmfc->ssss) if (tmfc->ssss)
{ {
int x; int x = tmfc->ssss;
if (tmfc->ssss > 3600) tm->tm_hour = x / 3600;
tm->tm_sec = x - ((tm->tm_min = (x = tmfc->ssss - x %= 3600;
((tm->tm_hour= tmfc->ssss / 3600) * 3600)) / 60) * 60); tm->tm_min = x / 60;
else if (tmfc->ssss > 60) x %= 60;
tm->tm_sec = tmfc->ssss - ((tm->tm_min = tmfc->ssss / 60) * 60); tm->tm_sec = x;
else
tm->tm_sec = tmfc->ssss;
} }
if (tmfc->cc) if (tmfc->cc)
......
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