|
8 | 8 | * |
9 | 9 | * |
10 | 10 | * IDENTIFICATION |
11 | | - * $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.84 2003/07/17 00:55:37 tgl Exp $ |
| 11 | + * $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.85 2003/07/24 00:21:26 tgl Exp $ |
12 | 12 | * |
13 | 13 | *------------------------------------------------------------------------- |
14 | 14 | */ |
@@ -348,17 +348,17 @@ timestamp_date(PG_FUNCTION_ARGS) |
348 | 348 | { |
349 | 349 | Timestamptimestamp=PG_GETARG_TIMESTAMP(0); |
350 | 350 | DateADTresult; |
| 351 | +structtmtt, |
| 352 | +*tm=&tt; |
| 353 | +doublefsec; |
351 | 354 |
|
352 | 355 | if (TIMESTAMP_NOT_FINITE(timestamp)) |
353 | 356 | PG_RETURN_NULL(); |
354 | 357 |
|
355 | | -#ifdefHAVE_INT64_TIMESTAMP |
356 | | -/* Microseconds to days */ |
357 | | -result= (timestamp /INT64CONST(86400000000)); |
358 | | -#else |
359 | | -/* Seconds to days */ |
360 | | -result= (timestamp /86400.0); |
361 | | -#endif |
| 358 | +if (timestamp2tm(timestamp,NULL,tm,&fsec,NULL)!=0) |
| 359 | +elog(ERROR,"Unable to convert timestamp to date"); |
| 360 | + |
| 361 | +result=date2j(tm->tm_year,tm->tm_mon,tm->tm_mday)-POSTGRES_EPOCH_JDATE; |
362 | 362 |
|
363 | 363 | PG_RETURN_DATEADT(result); |
364 | 364 | } |
|