1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-14 18:42:34 +03:00

Code & docs review for server instrumentation patch. File timestamps

should surely be timestamptz not timestamp; fix some but not all of the
holes in check_and_make_absolute(); other minor cleanup.  Also put in
the missed catversion bump.
This commit is contained in:
Tom Lane
2005-08-12 18:23:56 +00:00
parent cb29f669b0
commit a43ea120bf
8 changed files with 210 additions and 165 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.147 2005/07/30 18:20:44 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.148 2005/08/12 18:23:54 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -939,7 +939,7 @@ GetCurrentTimestamp(void)
gettimeofday(&tp, NULL);
result = tp.tv_sec -
result = (TimestampTz) tp.tv_sec -
((POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * SECS_PER_DAY);
#ifdef HAVE_INT64_TIMESTAMP
@ -951,6 +951,29 @@ GetCurrentTimestamp(void)
return result;
}
/*
* Convert a time_t to TimestampTz.
*
* We do not use time_t internally in Postgres, but this is provided for use
* by functions that need to interpret, say, a stat(2) result.
*/
TimestampTz
time_t_to_timestamptz(time_t tm)
{
TimestampTz result;
result = (TimestampTz) tm -
((POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * SECS_PER_DAY);
#ifdef HAVE_INT64_TIMESTAMP
result *= USECS_PER_SEC;
#endif
return result;
}
void
dt2time(Timestamp jd, int *hour, int *min, int *sec, fsec_t *fsec)
{