aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/timestamp.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2005-07-30 18:20:44 +0000
committerBruce Momjian <bruce@momjian.us>2005-07-30 18:20:44 +0000
commit5b5013f50262d257c34d0699fe29ffd7666eeec2 (patch)
treea6cb98a0a1d07f8068f30ad443b58ec967d0f8df /src/backend/utils/adt/timestamp.c
parent08d728372e8ce803fe096bacfb6330328f61dcf4 (diff)
downloadpostgresql-5b5013f50262d257c34d0699fe29ffd7666eeec2.tar.gz
postgresql-5b5013f50262d257c34d0699fe29ffd7666eeec2.zip
Fix justify_days() for integer datestamp, clean up code.
Diffstat (limited to 'src/backend/utils/adt/timestamp.c')
-rw-r--r--src/backend/utils/adt/timestamp.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c
index 85c5bda35f4..62c6effbfe3 100644
--- a/src/backend/utils/adt/timestamp.c
+++ b/src/backend/utils/adt/timestamp.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.146 2005/07/24 04:37:07 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.147 2005/07/30 18:20:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1915,8 +1915,7 @@ interval_justify_hours(PG_FUNCTION_ARGS)
#ifdef HAVE_INT64_TIMESTAMP
result->time += span->day * USECS_PER_DAY;
- result->day = result->time / USECS_PER_DAY;
- result->time -= result->day * USECS_PER_DAY;
+ TMODULO(result->time, result->day, USECS_PER_DAY);
#else
result->time += span->day * (double)SECS_PER_DAY;
TMODULO(result->time, result->day, (double)SECS_PER_DAY);
@@ -1939,14 +1938,8 @@ interval_justify_days(PG_FUNCTION_ARGS)
result->day = span->day;
result->time = span->time;
-#ifdef HAVE_INT64_TIMESTAMP
- result->day += span->month * (double)DAYS_PER_MONTH;
- result->month = span->day / DAYS_PER_MONTH;
- result->day -= result->month * DAYS_PER_MONTH;
-#else
- result->day += span->month * (double)DAYS_PER_MONTH;
- TMODULO(result->day, result->month, (double)DAYS_PER_MONTH);
-#endif
+ result->day += span->month * DAYS_PER_MONTH;
+ TMODULO(result->day, result->month, DAYS_PER_MONTH);
PG_RETURN_INTERVAL_P(result);
}