Index: doc/src/sgml/func.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/func.sgml,v
retrieving revision 1.282
diff -c -c -r1.282 func.sgml
*** doc/src/sgml/func.sgml	24 Aug 2005 20:49:35 -0000	1.282
--- doc/src/sgml/func.sgml	25 Aug 2005 01:26:36 -0000
***************
*** 5189,5194 ****
--- 5189,5200 ----
      </table>
  
     <para>
+     If you are using both <function>justify_hours</> and <function>justify_days</>,
+     it is best to use <function>justify_hours</> first so any additional days will
+     justified by <function>justify_days</>.
+    </para>
+ 
+    <para>
      In addition to these functions, the SQL <literal>OVERLAPS</> operator is
      supported:
  <synopsis>
Index: src/backend/utils/adt/timestamp.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v
retrieving revision 1.148
diff -c -c -r1.148 timestamp.c
*** src/backend/utils/adt/timestamp.c	12 Aug 2005 18:23:54 -0000	1.148
--- src/backend/utils/adt/timestamp.c	25 Aug 2005 01:26:39 -0000
***************
*** 1892,1898 ****
  {
  	Timestamp	dt1 = PG_GETARG_TIMESTAMP(0);
  	Timestamp	dt2 = PG_GETARG_TIMESTAMP(1);
! 	Interval   *result;
  
  	result = (Interval *) palloc(sizeof(Interval));
  
--- 1892,1898 ----
  {
  	Timestamp	dt1 = PG_GETARG_TIMESTAMP(0);
  	Timestamp	dt2 = PG_GETARG_TIMESTAMP(1);
! 	Interval   *result, *result2;
  
  	result = (Interval *) palloc(sizeof(Interval));
  
***************
*** 1914,1922 ****
  	result->month = 0;
  	result->day = 0;
  
! 	result = DatumGetIntervalP(DirectFunctionCall1(interval_justify_hours,
  												IntervalPGetDatum(result)));
! 	PG_RETURN_INTERVAL_P(result);
  }
  
  /*	interval_justify_hours()
--- 1914,1923 ----
  	result->month = 0;
  	result->day = 0;
  
! 	result2 = DatumGetIntervalP(DirectFunctionCall1(interval_justify_hours,
  												IntervalPGetDatum(result)));
! 	pfree(result);
! 	PG_RETURN_INTERVAL_P(result2);
  }
  
  /*	interval_justify_hours()
***************
*** 2263,2269 ****
  	Interval   *span = PG_GETARG_INTERVAL_P(0);
  	float8		factor = PG_GETARG_FLOAT8(1);
  	double		month_remainder, day_remainder;
! 	Interval   *result;
  
  	result = (Interval *) palloc(sizeof(Interval));
  
--- 2264,2270 ----
  	Interval   *span = PG_GETARG_INTERVAL_P(0);
  	float8		factor = PG_GETARG_FLOAT8(1);
  	double		month_remainder, day_remainder;
! 	Interval   *result, *result2;
  
  	result = (Interval *) palloc(sizeof(Interval));
  
***************
*** 2289,2297 ****
  					day_remainder * SECS_PER_DAY);
  #endif
  
! 	result = DatumGetIntervalP(DirectFunctionCall1(interval_justify_hours,
  												IntervalPGetDatum(result)));
! 	PG_RETURN_INTERVAL_P(result);
  }
  
  Datum
--- 2290,2299 ----
  					day_remainder * SECS_PER_DAY);
  #endif
  
! 	result2 = DatumGetIntervalP(DirectFunctionCall1(interval_justify_hours,
  												IntervalPGetDatum(result)));
! 	pfree(result);
! 	PG_RETURN_INTERVAL_P(result2);
  }
  
  Datum
***************
*** 2310,2316 ****
  	Interval   *span = PG_GETARG_INTERVAL_P(0);
  	float8		factor = PG_GETARG_FLOAT8(1);
  	double		month_remainder, day_remainder;
! 	Interval   *result;
  
  	result = (Interval *) palloc(sizeof(Interval));
  
--- 2312,2318 ----
  	Interval   *span = PG_GETARG_INTERVAL_P(0);
  	float8		factor = PG_GETARG_FLOAT8(1);
  	double		month_remainder, day_remainder;
! 	Interval   *result, *result2;
  
  	result = (Interval *) palloc(sizeof(Interval));
  
***************
*** 2341,2349 ****
  	result->time = JROUND(result->time);
  #endif
  
! 	result = DatumGetIntervalP(DirectFunctionCall1(interval_justify_hours,
  												IntervalPGetDatum(result)));
! 	PG_RETURN_INTERVAL_P(result);
  }
  
  /*
--- 2343,2352 ----
  	result->time = JROUND(result->time);
  #endif
  
! 	result2 = DatumGetIntervalP(DirectFunctionCall1(interval_justify_hours,
  												IntervalPGetDatum(result)));
! 	pfree(result);
! 	PG_RETURN_INTERVAL_P(result2);
  }
  
  /*
