|
7 | 7 | *
|
8 | 8 | *
|
9 | 9 | * IDENTIFICATION
|
10 |
| - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.79 2000/01/02 02:32:37 momjian Exp $ |
| 10 | + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.80 2000/01/04 07:53:27 thomas Exp $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
@@ -787,6 +787,7 @@ datetime_mi(DateTime *datetime1, DateTime *datetime2)
|
787 | 787 | * To add a month, increment the month, and use the same day of month.
|
788 | 788 | * Then, if the next month has fewer days, set the day of month
|
789 | 789 | * to the last day of month.
|
| 790 | + * Lastly, add in the "quantitative time". |
790 | 791 | */
|
791 | 792 | DateTime *
|
792 | 793 | datetime_pl_span(DateTime *datetime, TimeSpan *span)
|
@@ -815,12 +816,6 @@ datetime_pl_span(DateTime *datetime, TimeSpan *span)
|
815 | 816 | {
|
816 | 817 | dt = (DATETIME_IS_RELATIVE(*datetime) ? SetDateTime(*datetime) : *datetime);
|
817 | 818 |
|
818 |
| -#ifdef ROUND_ALL |
819 |
| - dt = JROUND(dt + span->time); |
820 |
| -#else |
821 |
| - dt += span->time; |
822 |
| -#endif |
823 |
| - |
824 | 819 | if (span->month != 0)
|
825 | 820 | {
|
826 | 821 | struct tm tt,
|
@@ -853,6 +848,12 @@ datetime_pl_span(DateTime *datetime, TimeSpan *span)
|
853 | 848 | DATETIME_INVALID(dt);
|
854 | 849 | }
|
855 | 850 |
|
| 851 | +#ifdef ROUND_ALL |
| 852 | + dt = JROUND(dt + span->time); |
| 853 | +#else |
| 854 | + dt += span->time; |
| 855 | +#endif |
| 856 | + |
856 | 857 | *result = dt;
|
857 | 858 | }
|
858 | 859 |
|
@@ -2441,7 +2442,10 @@ static int
|
2441 | 2442 | tm2timespan(struct tm * tm, double fsec, TimeSpan *span)
|
2442 | 2443 | {
|
2443 | 2444 | span->month = ((tm->tm_year * 12) + tm->tm_mon);
|
2444 |
| - span->time = ((((((tm->tm_mday * 24) + tm->tm_hour) * 60) + tm->tm_min) * 60) + tm->tm_sec); |
| 2445 | + span->time = ((((((tm->tm_mday * 24.0) |
| 2446 | + + tm->tm_hour) * 60.0) |
| 2447 | + + tm->tm_min) * 60.0) |
| 2448 | + + tm->tm_sec); |
2445 | 2449 | span->time = JROUND(span->time + fsec);
|
2446 | 2450 |
|
2447 | 2451 | return 0;
|
|
0 commit comments