summaryrefslogtreecommitdiff
path: root/src/include/gtm/gtm_time.h
blob: 9bcb8e5f79562ea03696bac1a0bdf89489e9fdbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*-------------------------------------------------------------------------
 *
 * gtm_time.h
 *
 *
 * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
 * Portions Copyright (c) 1994, Regents of the University of California
 * Portions Copyright (c) 2010-2012 Postgres-XC Development Group
 *
 * $PostgreSQL$
 *
 *-------------------------------------------------------------------------
 */

#ifndef GTM_TIME_H
#define GTM_TIME_H

/* Julian-date equivalents of Day 0 in Unix and GTM reckoning */
#define UNIX_EPOCH_JDATE	2440588 /* == date2j(1970, 1, 1) */
#define GTM_EPOCH_JDATE		2451545 /* == date2j(2000, 1, 1) */

#define SECS_PER_YEAR	(36525 * 864)	/* avoid floating-point computation */
#define SECS_PER_DAY	86400
#define SECS_PER_HOUR	3600
#define SECS_PER_MINUTE	60
#define MINS_PER_HOUR	60

#ifdef HAVE_INT64_TIMESTAMP
#define USECS_PER_DAY		INT64CONST(86400000000)
#define USECS_PER_HOUR		INT64CONST(3600000000)
#define USECS_PER_MINUTE	INT64CONST(60000000)
#define USECS_PER_SEC		INT64CONST(1000000)
#endif

GTM_Timestamp GTM_TimestampGetCurrent(void);
void GTM_TimestampDifference(GTM_Timestamp start_time, GTM_Timestamp stop_time,
					long *secs, int *microsecs);
bool GTM_TimestampDifferenceExceeds(GTM_Timestamp start_time,
						   GTM_Timestamp stop_time,
						   int msec);

#endif