Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit17adf80

Browse files
author
Thomas G. Lockhart
committed
Fix timestamp to date conversion for the case where timestamp uses a double
precision storage format. Previously applied the same math as used for the 64-bit integer storage format case, which was wrong. Problem introduced recently when the 64-bit storage format was implemented.
1 parent606db06 commit17adf80

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

‎src/backend/utils/adt/date.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.66 2002/04/21 19:48:12 thomas Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.67 2002/06/01 15:52:15 thomas Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -308,22 +308,16 @@ timestamp_date(PG_FUNCTION_ARGS)
308308
{
309309
Timestamptimestamp=PG_GETARG_TIMESTAMP(0);
310310
DateADTresult;
311-
#if0
312-
structtmtt,
313-
*tm=&tt;
314-
fsec_tfsec;
315-
#endif
316311

317312
if (TIMESTAMP_NOT_FINITE(timestamp))
318313
PG_RETURN_NULL();
319314

320-
#if0
321-
if (timestamp2tm(timestamp,NULL,tm,&fsec,NULL)!=0)
322-
elog(ERROR,"Unable to convert timestamp to date");
323-
324-
result=date2j(tm->tm_year,tm->tm_mon,tm->tm_mday)-date2j(2000,1,1);
325-
#else
315+
#ifdefHAVE_INT64_TIMESTAMP
316+
/* Microseconds to days */
326317
result= (timestamp /INT64CONST(86400000000));
318+
#else
319+
/* Seconds to days */
320+
result= (timestamp /86400.0);
327321
#endif
328322

329323
PG_RETURN_DATEADT(result);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp