PostgreSQL Source Code  git master
timestamp.h File Reference
#include "datatype/timestamp.h"
#include "fmgr.h"
#include "pgtime.h"
Include dependency graph for timestamp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DatumGetTimestamp(X)   ((Timestamp) DatumGetInt64(X))
 
#define DatumGetTimestampTz(X)   ((TimestampTz) DatumGetInt64(X))
 
#define DatumGetIntervalP(X)   ((Interval *) DatumGetPointer(X))
 
#define TimestampGetDatum(X)   Int64GetDatum(X)
 
#define TimestampTzGetDatum(X)   Int64GetDatum(X)
 
#define IntervalPGetDatum(X)   PointerGetDatum(X)
 
#define PG_GETARG_TIMESTAMP(n)   DatumGetTimestamp(PG_GETARG_DATUM(n))
 
#define PG_GETARG_TIMESTAMPTZ(n)   DatumGetTimestampTz(PG_GETARG_DATUM(n))
 
#define PG_GETARG_INTERVAL_P(n)   DatumGetIntervalP(PG_GETARG_DATUM(n))
 
#define PG_RETURN_TIMESTAMP(x)   return TimestampGetDatum(x)
 
#define PG_RETURN_TIMESTAMPTZ(x)   return TimestampTzGetDatum(x)
 
#define PG_RETURN_INTERVAL_P(x)   return IntervalPGetDatum(x)
 
#define TIMESTAMP_MASK(b)   (1 << (b))
 
#define INTERVAL_MASK(b)   (1 << (b))
 
#define INTERVAL_FULL_RANGE   (0x7FFF)
 
#define INTERVAL_RANGE_MASK   (0x7FFF)
 
#define INTERVAL_FULL_PRECISION   (0xFFFF)
 
#define INTERVAL_PRECISION_MASK   (0xFFFF)
 
#define INTERVAL_TYPMOD(p, r)   ((((r) & INTERVAL_RANGE_MASK) << 16) | ((p) & INTERVAL_PRECISION_MASK))
 
#define INTERVAL_PRECISION(t)   ((t) & INTERVAL_PRECISION_MASK)
 
#define INTERVAL_RANGE(t)   (((t) >> 16) & INTERVAL_RANGE_MASK)
 
#define TimestampTzPlusMilliseconds(tz, ms)   ((tz) + ((ms) * (int64) 1000))
 
#define timestamptz_cmp_internal(dt1, dt2)   timestamp_cmp_internal(dt1, dt2)
 

Functions

int32 anytimestamp_typmod_check (bool istz, int32 typmod)
 
TimestampTz GetCurrentTimestamp (void)
 
TimestampTz GetSQLCurrentTimestamp (int32 typmod)
 
Timestamp GetSQLLocalTimestamp (int32 typmod)
 
void TimestampDifference (TimestampTz start_time, TimestampTz stop_time, long *secs, int *microsecs)
 
long TimestampDifferenceMilliseconds (TimestampTz start_time, TimestampTz stop_time)
 
bool TimestampDifferenceExceeds (TimestampTz start_time, TimestampTz stop_time, int msec)
 
TimestampTz time_t_to_timestamptz (pg_time_t tm)
 
pg_time_t timestamptz_to_time_t (TimestampTz t)
 
const char * timestamptz_to_str (TimestampTz t)
 
int tm2timestamp (struct pg_tm *tm, fsec_t fsec, int *tzp, Timestamp *dt)
 
int timestamp2tm (Timestamp dt, int *tzp, struct pg_tm *tm, fsec_t *fsec, const char **tzn, pg_tz *attimezone)
 
void dt2time (Timestamp dt, int *hour, int *min, int *sec, fsec_t *fsec)
 
int interval2tm (Interval span, struct pg_tm *tm, fsec_t *fsec)
 
int tm2interval (struct pg_tm *tm, fsec_t fsec, Interval *span)
 
Timestamp SetEpochTimestamp (void)
 
void GetEpochTime (struct pg_tm *tm)
 
int timestamp_cmp_internal (Timestamp dt1, Timestamp dt2)
 
TimestampTz timestamp2timestamptz_opt_overflow (Timestamp timestamp, int *overflow)
 
int32 timestamp_cmp_timestamptz_internal (Timestamp timestampVal, TimestampTz dt2)
 
int isoweek2j (int year, int week)
 
void isoweek2date (int woy, int *year, int *mon, int *mday)
 
void isoweekdate2date (int isoweek, int wday, int *year, int *mon, int *mday)
 
int date2isoweek (int year, int mon, int mday)
 
int date2isoyear (int year, int mon, int mday)
 
int date2isoyearday (int year, int mon, int mday)
 
bool TimestampTimestampTzRequiresRewrite (void)
 

Variables

TimestampTz PgStartTime
 
TimestampTz PgReloadTime
 

Macro Definition Documentation

◆ DatumGetIntervalP

◆ DatumGetTimestamp

◆ DatumGetTimestampTz

◆ INTERVAL_FULL_PRECISION

#define INTERVAL_FULL_PRECISION   (0xFFFF)

◆ INTERVAL_FULL_RANGE

◆ INTERVAL_MASK

#define INTERVAL_MASK (   b)    (1 << (b))

◆ INTERVAL_PRECISION

#define INTERVAL_PRECISION (   t)    ((t) & INTERVAL_PRECISION_MASK)

Definition at line 53 of file timestamp.h.

Referenced by AdjustIntervalForTypmod(), interval_support(), and intervaltypmodout().

◆ INTERVAL_PRECISION_MASK

#define INTERVAL_PRECISION_MASK   (0xFFFF)

Definition at line 51 of file timestamp.h.

◆ INTERVAL_RANGE

#define INTERVAL_RANGE (   t)    (((t) >> 16) & INTERVAL_RANGE_MASK)

◆ INTERVAL_RANGE_MASK

#define INTERVAL_RANGE_MASK   (0x7FFF)

Definition at line 49 of file timestamp.h.

◆ INTERVAL_TYPMOD

#define INTERVAL_TYPMOD (   p,
 
)    ((((r) & INTERVAL_RANGE_MASK) << 16) | ((p) & INTERVAL_PRECISION_MASK))

Definition at line 52 of file timestamp.h.

Referenced by intervaltypmodin().

◆ IntervalPGetDatum

◆ PG_GETARG_INTERVAL_P

◆ PG_GETARG_TIMESTAMP

#define PG_GETARG_TIMESTAMP (   n)    DatumGetTimestamp(PG_GETARG_DATUM(n))

◆ PG_GETARG_TIMESTAMPTZ

◆ PG_RETURN_INTERVAL_P

◆ PG_RETURN_TIMESTAMP

◆ PG_RETURN_TIMESTAMPTZ

◆ TIMESTAMP_MASK

#define TIMESTAMP_MASK (   b)    (1 << (b))

Definition at line 44 of file timestamp.h.

◆ TimestampGetDatum

◆ timestamptz_cmp_internal

#define timestamptz_cmp_internal (   dt1,
  dt2 
)    timestamp_cmp_internal(dt1, dt2)

◆ TimestampTzGetDatum

◆ TimestampTzPlusMilliseconds

Function Documentation

◆ anytimestamp_typmod_check()

int32 anytimestamp_typmod_check ( bool  istz,
int32  typmod 
)

Definition at line 102 of file timestamp.c.

References ereport, errcode(), errmsg(), ERROR, MAX_TIMESTAMP_PRECISION, and WARNING.

Referenced by anytimestamp_typmodin(), and transformSQLValueFunction().

103 {
104  if (typmod < 0)
105  ereport(ERROR,
106  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
107  errmsg("TIMESTAMP(%d)%s precision must not be negative",
108  typmod, (istz ? " WITH TIME ZONE" : ""))));
109  if (typmod > MAX_TIMESTAMP_PRECISION)
110  {
112  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
113  errmsg("TIMESTAMP(%d)%s precision reduced to maximum allowed, %d",
114  typmod, (istz ? " WITH TIME ZONE" : ""),
116  typmod = MAX_TIMESTAMP_PRECISION;
117  }
118 
119  return typmod;
120 }
int errcode(int sqlerrcode)
Definition: elog.c:691
#define ERROR
Definition: elog.h:43
#define MAX_TIMESTAMP_PRECISION
Definition: timestamp.h:53
#define WARNING
Definition: elog.h:40
#define ereport(elevel,...)
Definition: elog.h:155
int errmsg(const char *fmt,...)
Definition: elog.c:902

◆ date2isoweek()

int date2isoweek ( int  year,
int  mon,
int  mday 
)

Definition at line 4332 of file timestamp.c.

References date2j(), and j2day().

Referenced by DCH_to_char(), timestamp_part(), timestamp_trunc(), timestamptz_part(), and timestamptz_trunc_internal().

4333 {
4334  float8 result;
4335  int day0,
4336  day4,
4337  dayn;
4338 
4339  /* current day */
4340  dayn = date2j(year, mon, mday);
4341 
4342  /* fourth day of current year */
4343  day4 = date2j(year, 1, 4);
4344 
4345  /* day0 == offset to first day of week (Monday) */
4346  day0 = j2day(day4 - 1);
4347 
4348  /*
4349  * We need the first week containing a Thursday, otherwise this day falls
4350  * into the previous year for purposes of counting weeks
4351  */
4352  if (dayn < day4 - day0)
4353  {
4354  day4 = date2j(year - 1, 1, 4);
4355 
4356  /* day0 == offset to first day of week (Monday) */
4357  day0 = j2day(day4 - 1);
4358  }
4359 
4360  result = (dayn - (day4 - day0)) / 7 + 1;
4361 
4362  /*
4363  * Sometimes the last few days in a year will fall into the first week of
4364  * the next year, so check for this.
4365  */
4366  if (result >= 52)
4367  {
4368  day4 = date2j(year + 1, 1, 4);
4369 
4370  /* day0 == offset to first day of week (Monday) */
4371  day0 = j2day(day4 - 1);
4372 
4373  if (dayn >= day4 - day0)
4374  result = (dayn - (day4 - day0)) / 7 + 1;
4375  }
4376 
4377  return (int) result;
4378 }
double float8
Definition: c.h:553
int j2day(int date)
Definition: datetime.c:327
int date2j(int y, int m, int d)
Definition: datetime.c:269

◆ date2isoyear()

int date2isoyear ( int  year,
int  mon,
int  mday 
)

Definition at line 4387 of file timestamp.c.

References date2j(), and j2day().

Referenced by date2isoyearday(), DCH_to_char(), timestamp_part(), and timestamptz_part().

4388 {
4389  float8 result;
4390  int day0,
4391  day4,
4392  dayn;
4393 
4394  /* current day */
4395  dayn = date2j(year, mon, mday);
4396 
4397  /* fourth day of current year */
4398  day4 = date2j(year, 1, 4);
4399 
4400  /* day0 == offset to first day of week (Monday) */
4401  day0 = j2day(day4 - 1);
4402 
4403  /*
4404  * We need the first week containing a Thursday, otherwise this day falls
4405  * into the previous year for purposes of counting weeks
4406  */
4407  if (dayn < day4 - day0)
4408  {
4409  day4 = date2j(year - 1, 1, 4);
4410 
4411  /* day0 == offset to first day of week (Monday) */
4412  day0 = j2day(day4 - 1);
4413 
4414  year--;
4415  }
4416 
4417  result = (dayn - (day4 - day0)) / 7 + 1;
4418 
4419  /*
4420  * Sometimes the last few days in a year will fall into the first week of
4421  * the next year, so check for this.
4422  */
4423  if (result >= 52)
4424  {
4425  day4 = date2j(year + 1, 1, 4);
4426 
4427  /* day0 == offset to first day of week (Monday) */
4428  day0 = j2day(day4 - 1);
4429 
4430  if (dayn >= day4 - day0)
4431  year++;
4432  }
4433 
4434  return year;
4435 }
double float8
Definition: c.h:553
int j2day(int date)
Definition: datetime.c:327
int date2j(int y, int m, int d)
Definition: datetime.c:269

◆ date2isoyearday()

int date2isoyearday ( int  year,
int  mon,
int  mday 
)

Definition at line 4444 of file timestamp.c.

References date2isoyear(), date2j(), and isoweek2j().

Referenced by DCH_to_char().

4445 {
4446  return date2j(year, mon, mday) - isoweek2j(date2isoyear(year, mon, mday), 1) + 1;
4447 }
int date2isoyear(int year, int mon, int mday)
Definition: timestamp.c:4387
int isoweek2j(int year, int week)
Definition: timestamp.c:4281
int date2j(int y, int m, int d)
Definition: datetime.c:269

◆ dt2time()

void dt2time ( Timestamp  dt,
int *  hour,
int *  min,
int *  sec,
fsec_t fsec 
)

Definition at line 1793 of file timestamp.c.

References USECS_PER_HOUR, USECS_PER_MINUTE, and USECS_PER_SEC.

Referenced by DecodeDateTime(), DecodeTimeOnly(), and timestamp2tm().

1794 {
1795  TimeOffset time;
1796 
1797  time = jd;
1798 
1799  *hour = time / USECS_PER_HOUR;
1800  time -= (*hour) * USECS_PER_HOUR;
1801  *min = time / USECS_PER_MINUTE;
1802  time -= (*min) * USECS_PER_MINUTE;
1803  *sec = time / USECS_PER_SEC;
1804  *fsec = time - (*sec * USECS_PER_SEC);
1805 } /* dt2time() */
#define USECS_PER_SEC
Definition: timestamp.h:94
#define USECS_PER_MINUTE
Definition: timestamp.h:93
#define USECS_PER_HOUR
Definition: timestamp.h:92
int64 TimeOffset
Definition: timestamp.h:40

◆ GetCurrentTimestamp()

TimestampTz GetCurrentTimestamp ( void  )

Definition at line 1578 of file timestamp.c.

References gettimeofday(), POSTGRES_EPOCH_JDATE, SECS_PER_DAY, UNIX_EPOCH_JDATE, and USECS_PER_SEC.

Referenced by ApplyLauncherMain(), ApplyWorkerMain(), asyncQueueFillWarning(), autoprewarm_main(), autovac_refresh_stats(), AutoVacLauncherMain(), backend_read_statsfile(), BackgroundWriterMain(), check_log_duration(), CheckPointGuts(), CleanupBackgroundWorker(), clock_timestamp(), CreateCheckPoint(), CreateEndOfRecoveryRecord(), CreateRestartPoint(), DetermineSleepTime(), disable_timeout(), disable_timeouts(), do_analyze_rel(), do_start_bgworker(), do_start_worker(), drandom(), enable_timeout_after(), enable_timeout_at(), enable_timeouts(), get_role_password(), GetCurrentTransactionStopTimestamp(), GetReplicationApplyDelay(), GetSnapshotCurrentTimestamp(), handle_sig_alarm(), heap_vacuum_rel(), InitProcessGlobals(), launcher_determine_sleep(), log_disconnections(), LogCheckpointEnd(), logicalrep_worker_launch(), LogicalRepApplyLoop(), maybe_start_bgworkers(), perform_base_backup(), pgfdw_cancel_query(), pgfdw_exec_cleanup_query(), pgfdw_get_cleanup_result(), pgstat_read_statsfiles(), pgstat_recv_inquiry(), pgstat_recv_resetreplslotcounter(), pgstat_recv_resetsharedcounter(), pgstat_recv_resetsinglecounter(), pgstat_recv_resetslrucounter(), pgstat_report_activity(), pgstat_report_analyze(), pgstat_report_autovac(), pgstat_report_checksum_failures_in_db(), pgstat_report_vacuum(), pgstat_send_archiver(), pgstat_write_statsfiles(), PostgresMain(), PostmasterMain(), PrepareTransaction(), process_syncing_tables_for_apply(), ProcessRepliesIfAny(), ProcessStandbyReplyMessage(), ProcessWalSndrMessage(), ProcSleep(), rebuild_database_list(), RecordTransactionAbort(), RecordTransactionAbortPrepared(), RecordTransactionCommitPrepared(), recoveryApplyDelay(), reschedule_timeouts(), reset_dbentry_counters(), ResolveRecoveryConflictWithBufferPin(), ResolveRecoveryConflictWithLock(), ResolveRecoveryConflictWithVirtualXIDs(), send_feedback(), SetCurrentStatementStartTimestamp(), SetCurrentTransactionStopTimestamp(), StartTransaction(), StartupXLOG(), test_pattern(), throttle(), UpdateWorkerStats(), WaitExceedsMaxStandbyDelay(), WaitForWALToBecomeAvailable(), WalReceiverMain(), WalSndKeepalive(), WalSndLoop(), WalSndUpdateProgress(), WalSndWaitForWal(), WalSndWriteData(), XLogBackgroundFlush(), XLogFileRead(), XLogRestorePoint(), XLogSendPhysical(), XLogWalRcvSendHSFeedback(), and XLogWalRcvSendReply().

1579 {
1580  TimestampTz result;
1581  struct timeval tp;
1582 
1583  gettimeofday(&tp, NULL);
1584 
1585  result = (TimestampTz) tp.tv_sec -
1587  result = (result * USECS_PER_SEC) + tp.tv_usec;
1588 
1589  return result;
1590 }
int gettimeofday(struct timeval *tp, struct timezone *tzp)
Definition: gettimeofday.c:104
#define USECS_PER_SEC
Definition: timestamp.h:94
int64 TimestampTz
Definition: timestamp.h:39
#define SECS_PER_DAY
Definition: timestamp.h:86
#define UNIX_EPOCH_JDATE
Definition: timestamp.h:162
#define POSTGRES_EPOCH_JDATE
Definition: timestamp.h:163

◆ GetEpochTime()

void GetEpochTime ( struct pg_tm tm)

Definition at line 2046 of file timestamp.c.

References elog, epoch, ERROR, pg_gmtime(), pg_tm::tm_hour, pg_tm::tm_mday, pg_tm::tm_min, pg_tm::tm_mon, pg_tm::tm_sec, and pg_tm::tm_year.

Referenced by date_in(), PGTYPESdate_from_asc(), and SetEpochTimestamp().

2047 {
2048  struct pg_tm *t0;
2049  pg_time_t epoch = 0;
2050 
2051  t0 = pg_gmtime(&epoch);
2052 
2053  if (t0 == NULL)
2054  elog(ERROR, "could not convert epoch to timestamp: %m");
2055 
2056  tm->tm_year = t0->tm_year;
2057  tm->tm_mon = t0->tm_mon;
2058  tm->tm_mday = t0->tm_mday;
2059  tm->tm_hour = t0->tm_hour;
2060  tm->tm_min = t0->tm_min;
2061  tm->tm_sec = t0->tm_sec;
2062 
2063  tm->tm_year += 1900;
2064  tm->tm_mon++;
2065 }
int64 pg_time_t
Definition: pgtime.h:23
struct pg_tm * pg_gmtime(const pg_time_t *timep)
Definition: localtime.c:1387
int tm_hour
Definition: pgtime.h:29
Definition: pgtime.h:25
#define ERROR
Definition: elog.h:43
int tm_mday
Definition: pgtime.h:30
int tm_mon
Definition: pgtime.h:31
int tm_year
Definition: pgtime.h:32
#define elog(elevel,...)
Definition: elog.h:228
static const unsigned __int64 epoch
Definition: gettimeofday.c:34
int tm_sec
Definition: pgtime.h:27
int tm_min
Definition: pgtime.h:28

◆ GetSQLCurrentTimestamp()

TimestampTz GetSQLCurrentTimestamp ( int32  typmod)

Definition at line 1596 of file timestamp.c.

References AdjustTimestampForTypmod(), and GetCurrentTransactionStartTimestamp().

Referenced by ExecEvalSQLValueFunction().

1597 {
1598  TimestampTz ts;
1599 
1601  if (typmod >= 0)
1602  AdjustTimestampForTypmod(&ts, typmod);
1603  return ts;
1604 }
int64 TimestampTz
Definition: timestamp.h:39
void AdjustTimestampForTypmod(Timestamp *time, int32 typmod)
Definition: timestamp.c:392
TimestampTz GetCurrentTransactionStartTimestamp(void)
Definition: xact.c:798

◆ GetSQLLocalTimestamp()

Timestamp GetSQLLocalTimestamp ( int32  typmod)

Definition at line 1610 of file timestamp.c.

References AdjustTimestampForTypmod(), GetCurrentTransactionStartTimestamp(), and timestamptz2timestamp().

Referenced by ExecEvalSQLValueFunction().

1611 {
1612  Timestamp ts;
1613 
1615  if (typmod >= 0)
1616  AdjustTimestampForTypmod(&ts, typmod);
1617  return ts;
1618 }
void AdjustTimestampForTypmod(Timestamp *time, int32 typmod)
Definition: timestamp.c:392
static Timestamp timestamptz2timestamp(TimestampTz timestamp)
Definition: timestamp.c:5269
int64 Timestamp
Definition: timestamp.h:38
TimestampTz GetCurrentTransactionStartTimestamp(void)
Definition: xact.c:798

◆ interval2tm()

int interval2tm ( Interval  span,
struct pg_tm tm,
fsec_t fsec 
)

Definition at line 1964 of file timestamp.c.

References Interval::day, ereport, errcode(), errmsg(), ERROR, Interval::month, MONTHS_PER_YEAR, SAMESIGN, Interval::time, pg_tm::tm_hour, pg_tm::tm_mday, pg_tm::tm_min, pg_tm::tm_mon, pg_tm::tm_sec, pg_tm::tm_year, USECS_PER_HOUR, USECS_PER_MINUTE, and USECS_PER_SEC.

Referenced by interval_out(), interval_part(), interval_to_char(), and interval_trunc().

1965 {
1966  TimeOffset time;
1967  TimeOffset tfrac;
1968 
1969  tm->tm_year = span.month / MONTHS_PER_YEAR;
1970  tm->tm_mon = span.month % MONTHS_PER_YEAR;
1971  tm->tm_mday = span.day;
1972  time = span.time;
1973 
1974  tfrac = time / USECS_PER_HOUR;
1975  time -= tfrac * USECS_PER_HOUR;
1976  tm->tm_hour = tfrac;
1977  if (!SAMESIGN(tm->tm_hour, tfrac))
1978  ereport(ERROR,
1979  (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
1980  errmsg("interval out of range")));
1981  tfrac = time / USECS_PER_MINUTE;
1982  time -= tfrac * USECS_PER_MINUTE;
1983  tm->tm_min = tfrac;
1984  tfrac = time / USECS_PER_SEC;
1985  *fsec = time - (tfrac * USECS_PER_SEC);
1986  tm->tm_sec = tfrac;
1987 
1988  return 0;
1989 }
#define USECS_PER_SEC
Definition: timestamp.h:94
int tm_hour
Definition: pgtime.h:29
#define USECS_PER_MINUTE
Definition: timestamp.h:93
int errcode(int sqlerrcode)
Definition: elog.c:691
int32 day
Definition: timestamp.h:47
#define MONTHS_PER_YEAR
Definition: timestamp.h:69
#define ERROR
Definition: elog.h:43
int tm_mday
Definition: pgtime.h:30
int tm_mon
Definition: pgtime.h:31
#define USECS_PER_HOUR
Definition: timestamp.h:92
TimeOffset time
Definition: timestamp.h:45
#define SAMESIGN(a, b)
Definition: timestamp.c:47
int32 month
Definition: timestamp.h:48
int64 TimeOffset
Definition: timestamp.h:40
#define ereport(elevel,...)
Definition: elog.h:155
int tm_year
Definition: pgtime.h:32
int errmsg(const char *fmt,...)
Definition: elog.c:902
int tm_sec
Definition: pgtime.h:27
int tm_min
Definition: pgtime.h:28

◆ isoweek2date()

void isoweek2date ( int  woy,
int *  year,
int *  mon,
int *  mday 
)

Definition at line 4301 of file timestamp.c.

References isoweek2j(), and j2date().

Referenced by do_to_timestamp(), timestamp_trunc(), and timestamptz_trunc_internal().

4302 {
4303  j2date(isoweek2j(*year, woy), year, mon, mday);
4304 }
void j2date(int jd, int *year, int *month, int *day)
Definition: datetime.c:294
int isoweek2j(int year, int week)
Definition: timestamp.c:4281

◆ isoweek2j()

int isoweek2j ( int  year,
int  week 
)

Definition at line 4281 of file timestamp.c.

References date2j(), and j2day().

Referenced by date2isoyearday(), do_to_timestamp(), isoweek2date(), and isoweekdate2date().

4282 {
4283  int day0,
4284  day4;
4285 
4286  /* fourth day of current year */
4287  day4 = date2j(year, 1, 4);
4288 
4289  /* day0 == offset to first day of week (Monday) */
4290  day0 = j2day(day4 - 1);
4291 
4292  return ((week - 1) * 7) + (day4 - day0);
4293 }
int j2day(int date)
Definition: datetime.c:327
int date2j(int y, int m, int d)
Definition: datetime.c:269

◆ isoweekdate2date()

void isoweekdate2date ( int  isoweek,
int  wday,
int *  year,
int *  mon,
int *  mday 
)

Definition at line 4314 of file timestamp.c.

References isoweek2j(), and j2date().

Referenced by do_to_timestamp().

4315 {
4316  int jday;
4317 
4318  jday = isoweek2j(*year, isoweek);
4319  /* convert Gregorian week start (Sunday=1) to ISO week start (Monday=1) */
4320  if (wday > 1)
4321  jday += wday - 2;
4322  else
4323  jday += 6;
4324  j2date(jday, year, mon, mday);
4325 }
void j2date(int jd, int *year, int *month, int *day)
Definition: datetime.c:294
int isoweek2j(int year, int week)
Definition: timestamp.c:4281

◆ SetEpochTimestamp()

Timestamp SetEpochTimestamp ( void  )

Definition at line 2068 of file timestamp.c.

References GetEpochTime(), tm, and tm2timestamp().

Referenced by dttofmtasc_replace(), PGTYPEStimestamp_from_asc(), timestamp_in(), timestamp_part(), timestamptz_in(), and timestamptz_part().

2069 {
2070  Timestamp dt;
2071  struct pg_tm tt,
2072  *tm = &tt;
2073 
2074  GetEpochTime(tm);
2075  /* we don't bother to test for failure ... */
2076  tm2timestamp(tm, 0, NULL, &dt);
2077 
2078  return dt;
2079 } /* SetEpochTimestamp() */
Definition: pgtime.h:25
static struct pg_tm tm
Definition: localtime.c:102
int64 Timestamp
Definition: timestamp.h:38
int tm2timestamp(struct pg_tm *tm, fsec_t fsec, int *tzp, Timestamp *result)
Definition: timestamp.c:1916
void GetEpochTime(struct pg_tm *tm)
Definition: timestamp.c:2046

◆ time_t_to_timestamptz()

TimestampTz time_t_to_timestamptz ( pg_time_t  tm)

Definition at line 1730 of file timestamp.c.

References POSTGRES_EPOCH_JDATE, SECS_PER_DAY, UNIX_EPOCH_JDATE, and USECS_PER_SEC.

Referenced by pg_control_checkpoint(), pg_control_system(), pg_ls_dir_files(), and pg_stat_file().

1731 {
1732  TimestampTz result;
1733 
1734  result = (TimestampTz) tm -
1736  result *= USECS_PER_SEC;
1737 
1738  return result;
1739 }
#define USECS_PER_SEC
Definition: timestamp.h:94
int64 TimestampTz
Definition: timestamp.h:39
static struct pg_tm tm
Definition: localtime.c:102
#define SECS_PER_DAY
Definition: timestamp.h:86
#define UNIX_EPOCH_JDATE
Definition: timestamp.h:162
#define POSTGRES_EPOCH_JDATE
Definition: timestamp.h:163

◆ timestamp2timestamptz_opt_overflow()

TimestampTz timestamp2timestamptz_opt_overflow ( Timestamp  timestamp,
int *  overflow 
)

Definition at line 5200 of file timestamp.c.

References DetermineTimeZoneOffset(), dt2local(), ereport, errcode(), errmsg(), ERROR, IS_VALID_TIMESTAMP, MIN_TIMESTAMP, session_timezone, timestamp2tm(), TIMESTAMP_NOBEGIN, TIMESTAMP_NOEND, TIMESTAMP_NOT_FINITE, and tm.

Referenced by timestamp2timestamptz(), and timestamp_cmp_timestamptz_internal().

5201 {
5202  TimestampTz result;
5203  struct pg_tm tt,
5204  *tm = &tt;
5205  fsec_t fsec;
5206  int tz;
5207 
5208  if (overflow)
5209  *overflow = 0;
5210 
5212  return timestamp;
5213 
5214  /* We don't expect this to fail, but check it pro forma */
5215  if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL, NULL) == 0)
5216  {
5218 
5219  result = dt2local(timestamp, -tz);
5220 
5221  if (IS_VALID_TIMESTAMP(result))
5222  {
5223  return result;
5224  }
5225  else if (overflow)
5226  {
5227  if (result < MIN_TIMESTAMP)
5228  {
5229  *overflow = -1;
5230  TIMESTAMP_NOBEGIN(result);
5231  }
5232  else
5233  {
5234  *overflow = 1;
5235  TIMESTAMP_NOEND(result);
5236  }
5237  return result;
5238  }
5239  }
5240 
5241  ereport(ERROR,
5242  (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
5243  errmsg("timestamp out of range")));
5244 
5245  return 0;
5246 }
#define TIMESTAMP_NOEND(j)
Definition: timestamp.h:117
PGDLLIMPORT pg_tz * session_timezone
Definition: pgtz.c:28
int64 timestamp
int64 TimestampTz
Definition: timestamp.h:39
int timestamp2tm(Timestamp dt, int *tzp, struct pg_tm *tm, fsec_t *fsec, const char **tzn, pg_tz *attimezone)
Definition: timestamp.c:1820
int errcode(int sqlerrcode)
Definition: elog.c:691
Definition: pgtime.h:25
static struct pg_tm tm
Definition: localtime.c:102
#define TIMESTAMP_NOT_FINITE(j)
Definition: timestamp.h:122
#define ERROR
Definition: elog.h:43
int DetermineTimeZoneOffset(struct pg_tm *tm, pg_tz *tzp)
Definition: datetime.c:1478
#define TIMESTAMP_NOBEGIN(j)
Definition: timestamp.h:112
int32 fsec_t
Definition: timestamp.h:41
#define MIN_TIMESTAMP
Definition: timestamp.h:184
#define ereport(elevel,...)
Definition: elog.h:155
#define IS_VALID_TIMESTAMP(t)
Definition: timestamp.h:195
int errmsg(const char *fmt,...)
Definition: elog.c:902
static Timestamp dt2local(Timestamp dt, int timezone)
Definition: timestamp.c:2014

◆ timestamp2tm()

int timestamp2tm ( Timestamp  dt,
int *  tzp,
struct pg_tm tm,
fsec_t fsec,
const char **  tzn,
pg_tz attimezone 
)

Definition at line 1820 of file timestamp.c.

References dt2time(), j2date(), pg_localtime(), POSTGRES_EPOCH_JDATE, SECS_PER_DAY, session_timezone, pg_tm::tm_gmtoff, pg_tm::tm_hour, pg_tm::tm_isdst, pg_tm::tm_mday, pg_tm::tm_min, pg_tm::tm_mon, pg_tm::tm_sec, pg_tm::tm_year, pg_tm::tm_zone, TMODULO, UNIX_EPOCH_JDATE, USECS_PER_DAY, and USECS_PER_SEC.

Referenced by DetermineTimeZoneAbbrevOffsetTS(), GetCurrentTimeUsec(), JsonEncodeDateTime(), make_timestamptz_at_timezone(), map_sql_value_to_xml_value(), pg_timezone_names(), PGTYPEStimestamp_add_interval(), PGTYPEStimestamp_fmt_asc(), PGTYPEStimestamp_to_asc(), timestamp2timestamptz_opt_overflow(), timestamp_age(), timestamp_date(), timestamp_out(), timestamp_part(), timestamp_pl_interval(), timestamp_recv(), timestamp_time(), timestamp_to_char(), timestamp_trunc(), timestamp_zone(), timestamptz2timestamp(), timestamptz_age(), timestamptz_date(), timestamptz_out(), timestamptz_part(), timestamptz_pl_interval(), timestamptz_recv(), timestamptz_time(), timestamptz_timetz(), timestamptz_to_char(), timestamptz_to_str(), timestamptz_trunc_internal(), and timestamptz_zone().

1821 {
1822  Timestamp date;
1823  Timestamp time;
1824  pg_time_t utime;
1825 
1826  /* Use session timezone if caller asks for default */
1827  if (attimezone == NULL)
1828  attimezone = session_timezone;
1829 
1830  time = dt;
1831  TMODULO(time, date, USECS_PER_DAY);
1832 
1833  if (time < INT64CONST(0))
1834  {
1835  time += USECS_PER_DAY;
1836  date -= 1;
1837  }
1838 
1839  /* add offset to go from J2000 back to standard Julian date */
1840  date += POSTGRES_EPOCH_JDATE;
1841 
1842  /* Julian day routine does not work for negative Julian days */
1843  if (date < 0 || date > (Timestamp) INT_MAX)
1844  return -1;
1845 
1846  j2date((int) date, &tm->tm_year, &tm->tm_mon, &tm->tm_mday);
1847  dt2time(time, &tm->tm_hour, &tm->tm_min, &tm->tm_sec, fsec);
1848 
1849  /* Done if no TZ conversion wanted */
1850  if (tzp == NULL)
1851  {
1852  tm->tm_isdst = -1;
1853  tm->tm_gmtoff = 0;
1854  tm->tm_zone = NULL;
1855  if (tzn != NULL)
1856  *tzn = NULL;
1857  return 0;
1858  }
1859 
1860  /*
1861  * If the time falls within the range of pg_time_t, use pg_localtime() to
1862  * rotate to the local time zone.
1863  *
1864  * First, convert to an integral timestamp, avoiding possibly
1865  * platform-specific roundoff-in-wrong-direction errors, and adjust to
1866  * Unix epoch. Then see if we can convert to pg_time_t without loss. This
1867  * coding avoids hardwiring any assumptions about the width of pg_time_t,
1868  * so it should behave sanely on machines without int64.
1869  */
1870  dt = (dt - *fsec) / USECS_PER_SEC +
1872  utime = (pg_time_t) dt;
1873  if ((Timestamp) utime == dt)
1874  {
1875  struct pg_tm *tx = pg_localtime(&utime, attimezone);
1876 
1877  tm->tm_year = tx->tm_year + 1900;
1878  tm->tm_mon = tx->tm_mon + 1;
1879  tm->tm_mday = tx->tm_mday;
1880  tm->tm_hour = tx->tm_hour;
1881  tm->tm_min = tx->tm_min;
1882  tm->tm_sec = tx->tm_sec;
1883  tm->tm_isdst = tx->tm_isdst;
1884  tm->tm_gmtoff = tx->tm_gmtoff;
1885  tm->tm_zone = tx->tm_zone;
1886  *tzp = -tm->tm_gmtoff;
1887  if (tzn != NULL)
1888  *tzn = tm->tm_zone;
1889  }
1890  else
1891  {
1892  /*
1893  * When out of range of pg_time_t, treat as GMT
1894  */
1895  *tzp = 0;
1896  /* Mark this as *no* time zone available */
1897  tm->tm_isdst = -1;
1898  tm->tm_gmtoff = 0;
1899  tm->tm_zone = NULL;
1900  if (tzn != NULL)
1901  *tzn = NULL;
1902  }
1903 
1904  return 0;
1905 }
int64 pg_time_t
Definition: pgtime.h:23
PGDLLIMPORT pg_tz * session_timezone
Definition: pgtz.c:28
int tm_isdst
Definition: pgtime.h:35
#define USECS_PER_SEC
Definition: timestamp.h:94
int tm_hour
Definition: pgtime.h:29
long date
Definition: pgtypes_date.h:9
long int tm_gmtoff
Definition: pgtime.h:36
Definition: pgtime.h:25
#define SECS_PER_DAY
Definition: timestamp.h:86
int tm_mday
Definition: pgtime.h:30
int tm_mon
Definition: pgtime.h:31
#define USECS_PER_DAY
Definition: timestamp.h:91
const char * tm_zone
Definition: pgtime.h:37
void j2date(int jd, int *year, int *month, int *day)
Definition: datetime.c:294
int64 Timestamp
Definition: timestamp.h:38
void dt2time(Timestamp jd, int *hour, int *min, int *sec, fsec_t *fsec)
Definition: timestamp.c:1793
struct pg_tm * pg_localtime(const pg_time_t *timep, const pg_tz *tz)
Definition: localtime.c:1342
int tm_year
Definition: pgtime.h:32
#define UNIX_EPOCH_JDATE
Definition: timestamp.h:162
#define POSTGRES_EPOCH_JDATE
Definition: timestamp.h:163
int tm_sec
Definition: pgtime.h:27
int tm_min
Definition: pgtime.h:28
#define TMODULO(t, q, u)
Definition: datetime.h:249

◆ timestamp_cmp_internal()

int timestamp_cmp_internal ( Timestamp  dt1,
Timestamp  dt2 
)

◆ timestamp_cmp_timestamptz_internal()

int32 timestamp_cmp_timestamptz_internal ( Timestamp  timestampVal,
TimestampTz  dt2 
)

Definition at line 2192 of file timestamp.c.

References timestamp2timestamptz_opt_overflow(), TIMESTAMP_IS_NOBEGIN, TIMESTAMP_IS_NOEND, and timestamptz_cmp_internal.

Referenced by cmpTimestampToTimestampTz(), timestamp_cmp_timestamptz(), timestamp_eq_timestamptz(), timestamp_ge_timestamptz(), timestamp_gt_timestamptz(), timestamp_le_timestamptz(), timestamp_lt_timestamptz(), timestamp_ne_timestamptz(), timestamptz_cmp_timestamp(), timestamptz_eq_timestamp(), timestamptz_ge_timestamp(), timestamptz_gt_timestamp(), timestamptz_le_timestamp(), timestamptz_lt_timestamp(), and timestamptz_ne_timestamp().

2193 {
2194  TimestampTz dt1;
2195  int overflow;
2196 
2197  dt1 = timestamp2timestamptz_opt_overflow(timestampVal, &overflow);
2198  if (overflow > 0)
2199  {
2200  /* dt1 is larger than any finite timestamp, but less than infinity */
2201  return TIMESTAMP_IS_NOEND(dt2) ? -1 : +1;
2202  }
2203  if (overflow < 0)
2204  {
2205  /* dt1 is less than any finite timestamp, but more than -infinity */
2206  return TIMESTAMP_IS_NOBEGIN(dt2) ? +1 : -1;
2207  }
2208 
2209  return timestamptz_cmp_internal(dt1, dt2);
2210 }
int64 TimestampTz
Definition: timestamp.h:39
TimestampTz timestamp2timestamptz_opt_overflow(Timestamp timestamp, int *overflow)
Definition: timestamp.c:5200
#define timestamptz_cmp_internal(dt1, dt2)
Definition: timestamp.h:100
#define TIMESTAMP_IS_NOEND(j)
Definition: timestamp.h:120
#define TIMESTAMP_IS_NOBEGIN(j)
Definition: timestamp.h:115

◆ TimestampDifference()

void TimestampDifference ( TimestampTz  start_time,
TimestampTz  stop_time,
long *  secs,
int *  microsecs 
)

Definition at line 1654 of file timestamp.c.

References start_time, and USECS_PER_SEC.

Referenced by check_log_duration(), DetermineSleepTime(), heap_vacuum_rel(), launcher_determine_sleep(), log_disconnections(), ProcSleep(), and schedule_alarm().

1656 {
1657  TimestampTz diff = stop_time - start_time;
1658 
1659  if (diff <= 0)
1660  {
1661  *secs = 0;
1662  *microsecs = 0;
1663  }
1664  else
1665  {
1666  *secs = (long) (diff / USECS_PER_SEC);
1667  *microsecs = (int) (diff % USECS_PER_SEC);
1668  }
1669 }
#define USECS_PER_SEC
Definition: timestamp.h:94
int64 TimestampTz
Definition: timestamp.h:39
static time_t start_time
Definition: pg_ctl.c:99

◆ TimestampDifferenceExceeds()

◆ TimestampDifferenceMilliseconds()

long TimestampDifferenceMilliseconds ( TimestampTz  start_time,
TimestampTz  stop_time 
)

Definition at line 1691 of file timestamp.c.

References start_time.

Referenced by autoprewarm_main(), GetReplicationApplyDelay(), GetReplicationTransferLatency(), LogCheckpointEnd(), pgfdw_get_cleanup_result(), recoveryApplyDelay(), WaitForWALToBecomeAvailable(), and WalSndComputeSleeptime().

1692 {
1693  TimestampTz diff = stop_time - start_time;
1694 
1695  if (diff <= 0)
1696  return 0;
1697  else
1698  return (long) ((diff + 999) / 1000);
1699 }
int64 TimestampTz
Definition: timestamp.h:39
static time_t start_time
Definition: pg_ctl.c:99

◆ TimestampTimestampTzRequiresRewrite()

bool TimestampTimestampTzRequiresRewrite ( void  )

Definition at line 5169 of file timestamp.c.

References pg_get_timezone_offset(), and session_timezone.

Referenced by ATColumnChangeRequiresRewrite().

5170 {
5171  long offset;
5172 
5173  if (pg_get_timezone_offset(session_timezone, &offset) && offset == 0)
5174  return false;
5175  return true;
5176 }
PGDLLIMPORT pg_tz * session_timezone
Definition: pgtz.c:28
bool pg_get_timezone_offset(const pg_tz *tz, long int *gmtoff)
Definition: localtime.c:1849

◆ timestamptz_to_str()

const char* timestamptz_to_str ( TimestampTz  t)

Definition at line 1772 of file timestamp.c.

References buf, EncodeDateTime(), EncodeSpecialTimestamp(), MAXDATELEN, snprintf, strlcpy(), timestamp2tm(), TIMESTAMP_NOT_FINITE, timestamptz_to_time_t(), tm, USE_ISO_DATES, and USECS_PER_SEC.

Referenced by backend_read_statsfile(), commit_ts_desc(), CreateRestartPoint(), pg_decode_commit_txn(), pg_decode_stream_commit(), pgstat_recv_inquiry(), ProcessStandbyHSFeedbackMessage(), ProcessStandbyReplyMessage(), ProcessWalSndrMessage(), recoveryStopsAfter(), recoveryStopsBefore(), StartupXLOG(), xact_desc_abort(), xact_desc_commit(), xact_desc_prepare(), and xlog_desc().

1773 {
1774  static char buf[MAXDATELEN + 1];
1775  int tz;
1776  struct pg_tm tt,
1777  *tm = &tt;
1778  fsec_t fsec;
1779  const char *tzn;
1780 
1781  if (TIMESTAMP_NOT_FINITE(t))
1782  EncodeSpecialTimestamp(t, buf);
1783  else if (timestamp2tm(t, &tz, tm, &fsec, &tzn, NULL) == 0)
1784  EncodeDateTime(tm, fsec, true, tz, tzn, USE_ISO_DATES, buf);
1785  else
1786  strlcpy(buf, "(timestamp out of range)", sizeof(buf));
1787 
1788  return buf;
1789 }
#define MAXDATELEN
Definition: datetime.h:201
int timestamp2tm(Timestamp dt, int *tzp, struct pg_tm *tm, fsec_t *fsec, const char **tzn, pg_tz *attimezone)
Definition: timestamp.c:1820
void EncodeSpecialTimestamp(Timestamp dt, char *str)
Definition: timestamp.c:1531
Definition: pgtime.h:25
#define USE_ISO_DATES
Definition: miscadmin.h:214
static struct pg_tm tm
Definition: localtime.c:102
#define TIMESTAMP_NOT_FINITE(j)
Definition: timestamp.h:122
static char * buf
Definition: pg_test_fsync.c:68
void EncodeDateTime(struct pg_tm *tm, fsec_t fsec, bool print_tz, int tz, const char *tzn, int style, char *str)
Definition: datetime.c:4002
int32 fsec_t
Definition: timestamp.h:41
size_t strlcpy(char *dst, const char *src, size_t siz)
Definition: strlcpy.c:45

◆ timestamptz_to_time_t()

pg_time_t timestamptz_to_time_t ( TimestampTz  t)

Definition at line 1752 of file timestamp.c.

References POSTGRES_EPOCH_JDATE, SECS_PER_DAY, UNIX_EPOCH_JDATE, and USECS_PER_SEC.

Referenced by DetermineTimeZoneAbbrevOffsetTS(), InitProcessGlobals(), and timestamptz_to_str().

1753 {
1754  pg_time_t result;
1755 
1756  result = (pg_time_t) (t / USECS_PER_SEC +
1758 
1759  return result;
1760 }
int64 pg_time_t
Definition: pgtime.h:23
#define USECS_PER_SEC
Definition: timestamp.h:94
#define SECS_PER_DAY
Definition: timestamp.h:86
#define UNIX_EPOCH_JDATE
Definition: timestamp.h:162
#define POSTGRES_EPOCH_JDATE
Definition: timestamp.h:163

◆ tm2interval()

int tm2interval ( struct pg_tm tm,
fsec_t  fsec,
Interval span 
)

Definition at line 1992 of file timestamp.c.

References Interval::day, Interval::month, MONTHS_PER_YEAR, Interval::time, pg_tm::tm_hour, pg_tm::tm_mday, pg_tm::tm_min, pg_tm::tm_mon, pg_tm::tm_sec, pg_tm::tm_year, and USECS_PER_SEC.

Referenced by interval_in(), interval_trunc(), pg_timezone_abbrevs(), pg_timezone_names(), timestamp_age(), and timestamptz_age().

1993 {
1994  double total_months = (double) tm->tm_year * MONTHS_PER_YEAR + tm->tm_mon;
1995 
1996  if (total_months > INT_MAX || total_months < INT_MIN)
1997  return -1;
1998  span->month = total_months;
1999  span->day = tm->tm_mday;
2000  span->time = (((((tm->tm_hour * INT64CONST(60)) +
2001  tm->tm_min) * INT64CONST(60)) +
2002  tm->tm_sec) * USECS_PER_SEC) + fsec;
2003 
2004  return 0;
2005 }
#define USECS_PER_SEC
Definition: timestamp.h:94
int tm_hour
Definition: pgtime.h:29
int32 day
Definition: timestamp.h:47
#define MONTHS_PER_YEAR
Definition: timestamp.h:69
int tm_mday
Definition: pgtime.h:30
int tm_mon
Definition: pgtime.h:31
TimeOffset time
Definition: timestamp.h:45
int32 month
Definition: timestamp.h:48
int tm_year
Definition: pgtime.h:32
int tm_sec
Definition: pgtime.h:27
int tm_min
Definition: pgtime.h:28

◆ tm2timestamp()

int tm2timestamp ( struct pg_tm tm,
fsec_t  fsec,
int *  tzp,
Timestamp dt 
)

Definition at line 1916 of file timestamp.c.

References date2j(), dt2local(), IS_VALID_JULIAN, IS_VALID_TIMESTAMP, POSTGRES_EPOCH_JDATE, time2t(), pg_tm::tm_hour, pg_tm::tm_mday, pg_tm::tm_min, pg_tm::tm_mon, pg_tm::tm_sec, pg_tm::tm_year, and USECS_PER_DAY.

Referenced by check_recovery_target_time(), parse_datetime(), PGTYPEStimestamp_add_interval(), PGTYPEStimestamp_current(), PGTYPEStimestamp_defmt_scan(), PGTYPEStimestamp_from_asc(), SetEpochTimestamp(), timestamp_in(), timestamp_pl_interval(), timestamp_trunc(), timestamp_zone(), timestamptz2timestamp(), timestamptz_in(), timestamptz_pl_interval(), timestamptz_trunc_internal(), timestamptz_zone(), and to_timestamp().

1917 {
1918  TimeOffset date;
1919  TimeOffset time;
1920 
1921  /* Prevent overflow in Julian-day routines */
1922  if (!IS_VALID_JULIAN(tm->tm_year, tm->tm_mon, tm->tm_mday))
1923  {
1924  *result = 0; /* keep compiler quiet */
1925  return -1;
1926  }
1927 
1928  date = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - POSTGRES_EPOCH_JDATE;
1929  time = time2t(tm->tm_hour, tm->tm_min, tm->tm_sec, fsec);
1930 
1931  *result = date * USECS_PER_DAY + time;
1932  /* check for major overflow */
1933  if ((*result - time) / USECS_PER_DAY != date)
1934  {
1935  *result = 0; /* keep compiler quiet */
1936  return -1;
1937  }
1938  /* check for just-barely overflow (okay except time-of-day wraps) */
1939  /* caution: we want to allow 1999-12-31 24:00:00 */
1940  if ((*result < 0 && date > 0) ||
1941  (*result > 0 && date < -1))
1942  {
1943  *result = 0; /* keep compiler quiet */
1944  return -1;
1945  }
1946  if (tzp != NULL)
1947  *result = dt2local(*result, -(*tzp));
1948 
1949  /* final range check catches just-out-of-range timestamps */
1950  if (!IS_VALID_TIMESTAMP(*result))
1951  {
1952  *result = 0; /* keep compiler quiet */
1953  return -1;
1954  }
1955 
1956  return 0;
1957 }
static TimeOffset time2t(const int hour, const int min, const int sec, const fsec_t fsec)
Definition: timestamp.c:2008
int tm_hour
Definition: pgtime.h:29
long date
Definition: pgtypes_date.h:9
int tm_mday
Definition: pgtime.h:30
int tm_mon
Definition: pgtime.h:31
#define IS_VALID_JULIAN(y, m, d)
Definition: timestamp.h:155
#define USECS_PER_DAY
Definition: timestamp.h:91
int64 TimeOffset
Definition: timestamp.h:40
int date2j(int y, int m, int d)
Definition: datetime.c:269
#define IS_VALID_TIMESTAMP(t)
Definition: timestamp.h:195
int tm_year
Definition: pgtime.h:32
#define POSTGRES_EPOCH_JDATE
Definition: timestamp.h:163
static Timestamp dt2local(Timestamp dt, int timezone)
Definition: timestamp.c:2014
int tm_sec
Definition: pgtime.h:27
int tm_min
Definition: pgtime.h:28

Variable Documentation

◆ PgReloadTime

TimestampTz PgReloadTime

Definition at line 53 of file timestamp.c.

Referenced by pg_conf_load_time(), and PostmasterMarkPIDForWorkerNotify().

◆ PgStartTime