Skip to content

Commit 8fe55ef

Browse files
author
Thomas G. Lockhart
committed
Support special values 'now', 'current', etc on output.
1 parent f54cc39 commit 8fe55ef

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
char zone[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+
case EPOCH_ABSTIME:
35+
strcpy(buf, EPOCH);
36+
break;
37+
case INVALID_ABSTIME:
38+
strcpy(buf, INVALID);
39+
break;
40+
case CURRENT_ABSTIME:
41+
strcpy(buf, DCURRENT);
42+
break;
43+
case NOEND_ABSTIME:
44+
strcpy(buf, LATE);
45+
break;
46+
case NOSTART_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
return result;
38-
}
58+
} /* timestamp_out() */
3959

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy