mirror of
https://github.com/postgres/postgres.git
synced 2025-04-24 10:47:04 +03:00
Support special values 'now', 'current', etc on output.
This commit is contained in:
parent
f54cc390e1
commit
8fe55efd7b
@ -29,13 +29,33 @@ timestamp_out(time_t timestamp)
|
|||||||
char zone[MAXDATELEN + 1],
|
char zone[MAXDATELEN + 1],
|
||||||
*tzn = zone;
|
*tzn = zone;
|
||||||
|
|
||||||
|
switch (timestamp)
|
||||||
|
{
|
||||||
|
case EPOCH_ABSTIME:
|
||||||
|
strcpy(buf, EPOCH);
|
||||||
|
break;
|
||||||
|
case INVALID_ABSTIME:
|
||||||
|
strcpy(buf, INVALID);
|
||||||
|
break;
|
||||||
|
case CURRENT_ABSTIME:
|
||||||
|
strcpy(buf, DCURRENT);
|
||||||
|
break;
|
||||||
|
case NOEND_ABSTIME:
|
||||||
|
strcpy(buf, LATE);
|
||||||
|
break;
|
||||||
|
case NOSTART_ABSTIME:
|
||||||
|
strcpy(buf, EARLY);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
abstime2tm(timestamp, &tz, tm, tzn);
|
abstime2tm(timestamp, &tz, tm, tzn);
|
||||||
EncodeDateTime(tm, fsec, &tz, &tzn, USE_ISO_DATES, buf);
|
EncodeDateTime(tm, fsec, &tz, &tzn, USE_ISO_DATES, buf);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
result = palloc(strlen(buf) + 1);
|
result = palloc(strlen(buf) + 1);
|
||||||
strcpy(result, buf);
|
strcpy(result, buf);
|
||||||
return result;
|
return result;
|
||||||
}
|
} /* timestamp_out() */
|
||||||
|
|
||||||
time_t
|
time_t
|
||||||
now(void)
|
now(void)
|
||||||
@ -49,54 +69,36 @@ now(void)
|
|||||||
bool
|
bool
|
||||||
timestampeq(time_t t1, time_t t2)
|
timestampeq(time_t t1, time_t t2)
|
||||||
{
|
{
|
||||||
#if FALSE
|
|
||||||
return(t1 == t2);
|
|
||||||
#endif
|
|
||||||
return(abstimeeq(t1,t2));
|
return(abstimeeq(t1,t2));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
timestampne(time_t t1, time_t t2)
|
timestampne(time_t t1, time_t t2)
|
||||||
{
|
{
|
||||||
#if FALSE
|
|
||||||
return(t1 != t2);
|
|
||||||
#endif
|
|
||||||
return(abstimene(t1,t2));
|
return(abstimene(t1,t2));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
timestamplt(time_t t1, time_t t2)
|
timestamplt(time_t t1, time_t t2)
|
||||||
{
|
{
|
||||||
#if FALSE
|
|
||||||
return(t1 > t2);
|
|
||||||
#endif
|
|
||||||
return(abstimelt(t1,t2));
|
return(abstimelt(t1,t2));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
timestampgt(time_t t1, time_t t2)
|
timestampgt(time_t t1, time_t t2)
|
||||||
{
|
{
|
||||||
#if FALSE
|
|
||||||
return(t1 < t2);
|
|
||||||
#endif
|
|
||||||
return(abstimegt(t1,t2));
|
return(abstimegt(t1,t2));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
timestample(time_t t1, time_t t2)
|
timestample(time_t t1, time_t t2)
|
||||||
{
|
{
|
||||||
#if FALSE
|
|
||||||
return(t1 >= t2);
|
|
||||||
#endif
|
|
||||||
return(abstimele(t1,t2));
|
return(abstimele(t1,t2));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
timestampge(time_t t1, time_t t2)
|
timestampge(time_t t1, time_t t2)
|
||||||
{
|
{
|
||||||
#if FALSE
|
|
||||||
return(t1 <= t2);
|
|
||||||
#endif
|
|
||||||
return(abstimege(t1,t2));
|
return(abstimege(t1,t2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user