1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-03 20:02:46 +03:00

Add 'day' field to INTERVAL so 1 day interval can be distinguished from

24 hours. This is very helpful for daylight savings time:

	select '2005-05-03 00:00:00 EST'::timestamp with time zone + '24 hours';
	      ?column?
	----------------------
	2005-05-04 01:00:00-04

	select '2005-05-03 00:00:00 EST'::timestamp with time zone + '1 day';
	      ?column?
	----------------------
	2005-05-04 01:00:00-04

Michael Glaesemann
This commit is contained in:
Bruce Momjian
2005-07-20 16:42:32 +00:00
parent 826604f9e6
commit db05f4a7eb
12 changed files with 286 additions and 181 deletions

View File

@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.184 2005/07/12 16:04:57 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.185 2005/07/20 16:42:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -2784,10 +2784,11 @@ convert_timevalue_to_scalar(Datum value, Oid typid)
* too accurate, but plenty good enough for our purposes.
*/
#ifdef HAVE_INT64_TIMESTAMP
return (interval->time + (interval->month * ((365.25 / 12.0) * 86400000000.0)));
return interval->time + interval->day * (double)USECS_PER_DAY +
interval->month * ((365.25 / 12.0) * USECS_PER_DAY);
#else
return interval->time +
interval ->month * (365.25 / 12.0 * 24.0 * 60.0 * 60.0);
return interval->time + interval->day * SECS_PER_DAY +
interval->month * ((365.25 / 12.0) * (double)SECS_PER_DAY);
#endif
}
case RELTIMEOID: