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

Commit8507ddb

Browse files
author
Thomas G. Lockhart
committed
Use common parser and encoder for timestamp data type.
Remove older date and time code (retain NEW_DATE_CODE and NEW_TIME_CODE).Use common encoder for date and time.Fix datetime +/- timespan math bug.
1 parent43deb7a commit8507ddb

File tree

3 files changed

+625
-33
lines changed

3 files changed

+625
-33
lines changed

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

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.9 1997/06/23 14:47:26 thomas Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.10 1997/07/01 00:22:40 thomas Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -114,15 +114,24 @@ char *
114114
date_out(DateADTdate)
115115
{
116116
char*result;
117+
structtmtt,*tm=&tt;
117118
charbuf[MAXDATELEN+1];
119+
120+
#ifFALSE
118121
intyear,month,day;
122+
#endif
119123

120-
j2date( (date+date2j(2000,1,1)),&year,&month,&day);
124+
j2date( (date+date2j(2000,1,1)),
125+
&(tm->tm_year),&(tm->tm_mon),&(tm->tm_mday));
121126

127+
EncodeDateOnly(tm,DateStyle,buf);
128+
129+
#ifFALSE
122130
if (EuroDates==1)/* Output European-format dates */
123131
sprintf(buf,"%02d-%02d-%04d",day,month,year);
124132
else
125133
sprintf(buf,"%02d-%02d-%04d",month,day,year);
134+
#endif
126135

127136
result=PALLOC(strlen(buf)+1);
128137

@@ -445,19 +454,25 @@ char *
445454
time_out(TimeADT*time)
446455
{
447456
char*result;
457+
structtmtt,*tm=&tt;
458+
#ifFALSE
448459
inthour,min,sec;
460+
#endif
449461
doublefsec;
450-
charbuf[32];
462+
charbuf[MAXDATELEN+1];
451463

452464
if (!PointerIsValid(time))
453465
returnNULL;
454466

455-
hour= (*time / (60*60));
456-
min= (((int) (*time /60)) %60);
457-
sec= (((int)*time) %60);
467+
tm->tm_hour= (*time / (60*60));
468+
tm->tm_min= (((int) (*time /60)) %60);
469+
tm->tm_sec= (((int)*time) %60);
458470

459471
fsec=0;
460472

473+
EncodeTimeOnly(tm,fsec,DateStyle,buf);
474+
475+
#ifFALSE
461476
if (sec==0.0) {
462477
sprintf(buf,"%02d:%02d",hour,min);
463478

@@ -468,6 +483,7 @@ time_out(TimeADT *time)
468483
sprintf(buf,"%02d:%02d:%05.2f",hour,min, (sec+fsec));
469484
};
470485
};
486+
#endif
471487

472488
result=PALLOC(strlen(buf)+1);
473489

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp