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

Commit8fe55ef

Browse files
author
Thomas G. Lockhart
committed
Support special values 'now', 'current', etc on output.
1 parentf54cc39 commit8fe55ef

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

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

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,33 @@ timestamp_out(time_t timestamp)
2929
charzone[MAXDATELEN+1],
3030
*tzn=zone;
3131

32-
abstime2tm(timestamp,&tz,tm,tzn);
33-
EncodeDateTime(tm,fsec,&tz,&tzn,USE_ISO_DATES,buf);
34-
32+
switch (timestamp)
33+
{
34+
caseEPOCH_ABSTIME:
35+
strcpy(buf,EPOCH);
36+
break;
37+
caseINVALID_ABSTIME:
38+
strcpy(buf,INVALID);
39+
break;
40+
caseCURRENT_ABSTIME:
41+
strcpy(buf,DCURRENT);
42+
break;
43+
caseNOEND_ABSTIME:
44+
strcpy(buf,LATE);
45+
break;
46+
caseNOSTART_ABSTIME:
47+
strcpy(buf,EARLY);
48+
break;
49+
default:
50+
abstime2tm(timestamp,&tz,tm,tzn);
51+
EncodeDateTime(tm,fsec,&tz,&tzn,USE_ISO_DATES,buf);
52+
break;
53+
}
54+
3555
result=palloc(strlen(buf)+1);
3656
strcpy(result,buf);
3757
returnresult;
38-
}
58+
}/* timestamp_out() */
3959

4060
time_t
4161
now(void)
@@ -49,58 +69,40 @@ now(void)
4969
bool
5070
timestampeq(time_tt1,time_tt2)
5171
{
52-
#ifFALSE
53-
return(t1==t2);
54-
#endif
5572
return(abstimeeq(t1,t2));
5673
}
5774

5875
bool
5976
timestampne(time_tt1,time_tt2)
6077
{
61-
#ifFALSE
62-
return(t1!=t2);
63-
#endif
6478
return(abstimene(t1,t2));
6579
}
6680

6781
bool
6882
timestamplt(time_tt1,time_tt2)
6983
{
70-
#ifFALSE
71-
return(t1>t2);
72-
#endif
7384
return(abstimelt(t1,t2));
7485
}
7586

7687
bool
7788
timestampgt(time_tt1,time_tt2)
7889
{
79-
#ifFALSE
80-
return(t1<t2);
81-
#endif
8290
return(abstimegt(t1,t2));
8391
}
8492

8593
bool
8694
timestample(time_tt1,time_tt2)
8795
{
88-
#ifFALSE
89-
return(t1 >=t2);
90-
#endif
9196
return(abstimele(t1,t2));
9297
}
9398

9499
bool
95100
timestampge(time_tt1,time_tt2)
96101
{
97-
#ifFALSE
98-
return(t1 <=t2);
99-
#endif
100102
return(abstimege(t1,t2));
101103
}
102104

103-
DateTime*
105+
DateTime*
104106
timestamp_datetime(time_ttimestamp)
105107
{
106108
DateTime*result;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp