|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.121 2005/05/2318:56:55 momjian Exp $ |
| 11 | + * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.122 2005/05/2321:54:02 momjian Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -699,7 +699,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
|
699 | 699 | USECS_PER_DAY;
|
700 | 700 |
|
701 | 701 | #else
|
702 |
| -interval->time= ((int) (interval->time /86400))*86400; |
| 702 | +interval->time= ((int) (interval->time /SECS_PER_DAY))*SECS_PER_DAY; |
703 | 703 | #endif
|
704 | 704 | }
|
705 | 705 | elseif (range==INTERVAL_MASK(HOUR))
|
@@ -1021,7 +1021,7 @@ timestamp2tm(Timestamp dt, int *tzp, struct pg_tm * tm, fsec_t *fsec, char **tzn
|
1021 | 1021 |
|
1022 | 1022 | if (time<0)
|
1023 | 1023 | {
|
1024 |
| -time+=86400; |
| 1024 | +time+=SECS_PER_DAY; |
1025 | 1025 | date-=1;
|
1026 | 1026 | }
|
1027 | 1027 | #endif
|
@@ -1074,10 +1074,10 @@ timestamp2tm(Timestamp dt, int *tzp, struct pg_tm * tm, fsec_t *fsec, char **tzn
|
1074 | 1074 | */
|
1075 | 1075 | #ifdefHAVE_INT64_TIMESTAMP
|
1076 | 1076 | dt= (dt-*fsec) /USECS_PER_SEC+
|
1077 |
| -(POSTGRES_EPOCH_JDATE-UNIX_EPOCH_JDATE)*86400; |
| 1077 | +(POSTGRES_EPOCH_JDATE-UNIX_EPOCH_JDATE)*SECS_PER_DAY; |
1078 | 1078 | #else
|
1079 | 1079 | dt=rint(dt-*fsec+
|
1080 |
| - (POSTGRES_EPOCH_JDATE-UNIX_EPOCH_JDATE)*86400); |
| 1080 | + (POSTGRES_EPOCH_JDATE-UNIX_EPOCH_JDATE)*SECS_PER_DAY); |
1081 | 1081 | #endif
|
1082 | 1082 | utime= (pg_time_t)dt;
|
1083 | 1083 | if ((Timestamp)utime==dt)
|
@@ -1151,7 +1151,7 @@ tm2timestamp(struct pg_tm * tm, fsec_t fsec, int *tzp, Timestamp *result)
|
1151 | 1151 | (*result >=0&&date<0))
|
1152 | 1152 | return-1;
|
1153 | 1153 | #else
|
1154 |
| -*result=date*86400+time; |
| 1154 | +*result=date*SECS_PER_DAY+time; |
1155 | 1155 | #endif
|
1156 | 1156 | if (tzp!=NULL)
|
1157 | 1157 | *result=dt2local(*result,-(*tzp));
|
@@ -1621,9 +1621,9 @@ interval_cmp_internal(Interval *interval1, Interval *interval2)
|
1621 | 1621 | span2+=interval2->month*INT64CONST(30)*USECS_PER_DAY;
|
1622 | 1622 | #else
|
1623 | 1623 | if (interval1->month!=0)
|
1624 |
| -span1+=interval1->month* (30.0*86400); |
| 1624 | +span1+=interval1->month* (30.0*SECS_PER_DAY); |
1625 | 1625 | if (interval2->month!=0)
|
1626 |
| -span2+=interval2->month* (30.0*86400); |
| 1626 | +span2+=interval2->month* (30.0*SECS_PER_DAY); |
1627 | 1627 | #endif
|
1628 | 1628 |
|
1629 | 1629 | return ((span1<span2) ?-1 : (span1>span2) ?1 :0);
|
@@ -2166,7 +2166,7 @@ interval_mul(PG_FUNCTION_ARGS)
|
2166 | 2166 | result->month=rint(months);
|
2167 | 2167 | result->time=JROUND(span1->time*factor);
|
2168 | 2168 | /* evaluate fractional months as 30 days */
|
2169 |
| -result->time+=JROUND((months-result->month)*30*86400); |
| 2169 | +result->time+=JROUND((months-result->month)*30*SECS_PER_DAY); |
2170 | 2170 | #endif
|
2171 | 2171 |
|
2172 | 2172 | PG_RETURN_INTERVAL_P(result);
|
@@ -2211,7 +2211,7 @@ interval_div(PG_FUNCTION_ARGS)
|
2211 | 2211 | result->month=rint(months);
|
2212 | 2212 | result->time=JROUND(span->time /factor);
|
2213 | 2213 | /* evaluate fractional months as 30 days */
|
2214 |
| -result->time+=JROUND((months-result->month)*30*86400); |
| 2214 | +result->time+=JROUND((months-result->month)*30*SECS_PER_DAY); |
2215 | 2215 | #endif
|
2216 | 2216 |
|
2217 | 2217 | PG_RETURN_INTERVAL_P(result);
|
@@ -3788,8 +3788,8 @@ interval_part(PG_FUNCTION_ARGS)
|
3788 | 3788 | #endif
|
3789 | 3789 | if (interval->month!=0)
|
3790 | 3790 | {
|
3791 |
| -result+= (365.25*86400)* (interval->month /12); |
3792 |
| -result+= (30.0*86400)* (interval->month %12); |
| 3791 | +result+= (365.25*SECS_PER_DAY)* (interval->month /12); |
| 3792 | +result+= (30.0*SECS_PER_DAY)* (interval->month %12); |
3793 | 3793 | }
|
3794 | 3794 | }
|
3795 | 3795 | else
|
|