Skip to content

Commit 5b5013f

Browse files
committed
Fix justify_days() for integer datestamp, clean up code.
1 parent 08d7283 commit 5b5013f

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/backend/utils/adt/timestamp.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.146 2005/07/24 04:37:07 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.147 2005/07/30 18:20:44 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1915,8 +1915,7 @@ interval_justify_hours(PG_FUNCTION_ARGS)
19151915

19161916
#ifdef HAVE_INT64_TIMESTAMP
19171917
result->time += span->day * USECS_PER_DAY;
1918-
result->day = result->time / USECS_PER_DAY;
1919-
result->time -= result->day * USECS_PER_DAY;
1918+
TMODULO(result->time, result->day, USECS_PER_DAY);
19201919
#else
19211920
result->time += span->day * (double)SECS_PER_DAY;
19221921
TMODULO(result->time, result->day, (double)SECS_PER_DAY);
@@ -1939,14 +1938,8 @@ interval_justify_days(PG_FUNCTION_ARGS)
19391938
result->day = span->day;
19401939
result->time = span->time;
19411940

1942-
#ifdef HAVE_INT64_TIMESTAMP
1943-
result->day += span->month * (double)DAYS_PER_MONTH;
1944-
result->month = span->day / DAYS_PER_MONTH;
1945-
result->day -= result->month * DAYS_PER_MONTH;
1946-
#else
1947-
result->day += span->month * (double)DAYS_PER_MONTH;
1948-
TMODULO(result->day, result->month, (double)DAYS_PER_MONTH);
1949-
#endif
1941+
result->day += span->month * DAYS_PER_MONTH;
1942+
TMODULO(result->day, result->month, DAYS_PER_MONTH);
19501943

19511944
PG_RETURN_INTERVAL_P(result);
19521945
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy