diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-12-23 04:05:31 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-12-23 04:05:31 +0000 |
commit | a412749812823b03763b747080b57a3d316f33c4 (patch) | |
tree | 6d2ff7e90a2d85a008a74ff9febef39a1e1e0176 /src | |
parent | 90f42847b5ed5ed94a1221695e803d522db257b4 (diff) | |
download | postgresql-a412749812823b03763b747080b57a3d316f33c4.tar.gz postgresql-a412749812823b03763b747080b57a3d316f33c4.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/utils/adt/formatting.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index 2d540d38d8b..789b7b95130 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------- * 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 @@ -2775,16 +2775,14 @@ to_timestamp(PG_FUNCTION_ARGS) #endif if (tmfc->ssss) { - int x; - - if (tmfc->ssss > 3600) - tm->tm_sec = x - ((tm->tm_min = (x = tmfc->ssss - - ((tm->tm_hour= tmfc->ssss / 3600) * 3600)) / 60) * 60); - else if (tmfc->ssss > 60) - tm->tm_sec = tmfc->ssss - ((tm->tm_min = tmfc->ssss / 60) * 60); - else - tm->tm_sec = tmfc->ssss; - } + int x = tmfc->ssss; + + tm->tm_hour = x / 3600; + x %= 3600; + tm->tm_min = x / 60; + x %= 60; + tm->tm_sec = x; + } if (tmfc->cc) tm->tm_year = (tmfc->cc-1) * 100; |