1996-08-28 03:59:28 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* nabstime.h--
|
1997-09-07 07:04:48 +02:00
|
|
|
* Definitions for the "new" abstime code.
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
1998-02-13 18:12:08 +01:00
|
|
|
* $Id: nabstime.h,v 1.15 1998/02/13 17:12:08 scrappy Exp $
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef NABSTIME_H
|
|
|
|
#define NABSTIME_H
|
|
|
|
|
|
|
|
#include <time.h>
|
1997-03-15 00:34:16 +01:00
|
|
|
#include "utils/dt.h"
|
|
|
|
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
/* ----------------------------------------------------------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* time types + support macros
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* ----------------------------------------------------------------
|
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
typedef int32 AbsoluteTime;
|
|
|
|
typedef int32 RelativeTime;
|
1996-08-28 03:59:28 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
int32 status;
|
|
|
|
AbsoluteTime data[2];
|
1997-09-08 23:56:23 +02:00
|
|
|
} TimeIntervalData;
|
1996-08-28 03:59:28 +02:00
|
|
|
typedef TimeIntervalData *TimeInterval;
|
|
|
|
|
1997-03-15 00:34:16 +01:00
|
|
|
/*
|
|
|
|
* Reserved values
|
|
|
|
* Epoch is Unix system time zero, but needs to be kept as a reserved
|
1997-09-07 07:04:48 +02:00
|
|
|
* value rather than converting to time since timezone calculations
|
|
|
|
* might move it away from 1970-01-01 00:00:00Z - tgl 97/02/20
|
1997-03-15 00:34:16 +01:00
|
|
|
*
|
|
|
|
* Pre-v6.1 code had large decimal numbers for reserved values.
|
|
|
|
* These were chosen as special 32-bit bit patterns,
|
1997-09-07 07:04:48 +02:00
|
|
|
* so redefine them explicitly using these bit patterns. - tgl 97/02/24
|
1997-03-15 00:34:16 +01:00
|
|
|
*/
|
1996-08-28 03:59:28 +02:00
|
|
|
#define EPOCH_ABSTIME ((AbsoluteTime) 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
#define INVALID_ABSTIME ((AbsoluteTime) 0x7FFFFFFE) /* 2147483647 == 2^31 -
|
|
|
|
* 1 */
|
|
|
|
#define CURRENT_ABSTIME ((AbsoluteTime) 0x7FFFFFFD) /* 2147483646 == 2^31 -
|
|
|
|
* 2 */
|
|
|
|
#define NOEND_ABSTIME ((AbsoluteTime) 0x7FFFFFFC) /* 2147483645 == 2^31 -
|
|
|
|
* 3 */
|
|
|
|
#define BIG_ABSTIME ((AbsoluteTime) 0x7FFFFFFB) /* 2147483644 == 2^31 -
|
|
|
|
* 4 */
|
1996-08-28 03:59:28 +02:00
|
|
|
|
1998-02-13 18:12:08 +01:00
|
|
|
#if defined(_AIX)
|
1996-08-28 03:59:28 +02:00
|
|
|
/*
|
|
|
|
* AIX considers 2147483648 == -2147483648 (since they have the same bit
|
1997-09-07 07:04:48 +02:00
|
|
|
* representation) but uses a different sign sense in a comparison to
|
|
|
|
* these integer constants depending on whether the constant is signed
|
1996-08-28 03:59:28 +02:00
|
|
|
* or not!
|
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
#define NOSTART_ABSTIME ((AbsoluteTime) INT_MIN)
|
1996-08-28 03:59:28 +02:00
|
|
|
#else
|
1997-09-07 07:04:48 +02:00
|
|
|
#define NOSTART_ABSTIME ((AbsoluteTime) 0x80000001) /* -2147483647 == - 2^31 */
|
1998-02-13 18:12:08 +01:00
|
|
|
#endif /* _AIX */
|
1996-08-28 03:59:28 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
#define INVALID_RELTIME ((RelativeTime) 0x7FFFFFFE) /* 2147483647 == 2^31 -
|
|
|
|
* 1 */
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
#define AbsoluteTimeIsValid(time) \
|
1997-09-07 07:04:48 +02:00
|
|
|
((bool) ((time) != INVALID_ABSTIME))
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
#define AbsoluteTimeIsReal(time) \
|
1997-09-07 07:04:48 +02:00
|
|
|
((bool) (((AbsoluteTime) time) < NOEND_ABSTIME && \
|
|
|
|
((AbsoluteTime) time) > NOSTART_ABSTIME))
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
/* have to include this because EPOCH_ABSTIME used to be invalid - yuk */
|
|
|
|
#define AbsoluteTimeIsBackwardCompatiblyValid(time) \
|
1997-09-07 07:04:48 +02:00
|
|
|
((bool) (((AbsoluteTime) time) != INVALID_ABSTIME && \
|
|
|
|
((AbsoluteTime) time) > EPOCH_ABSTIME))
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
#define AbsoluteTimeIsBackwardCompatiblyReal(time) \
|
1997-09-07 07:04:48 +02:00
|
|
|
((bool) (((AbsoluteTime) time) < NOEND_ABSTIME && \
|
|
|
|
((AbsoluteTime) time) > NOSTART_ABSTIME && \
|
|
|
|
((AbsoluteTime) time) > EPOCH_ABSTIME))
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
#define RelativeTimeIsValid(time) \
|
1997-09-07 07:04:48 +02:00
|
|
|
((bool) (((RelativeTime) time) != INVALID_RELTIME))
|
1996-08-28 03:59:28 +02:00
|
|
|
|
1997-03-15 00:34:16 +01:00
|
|
|
extern AbsoluteTime GetCurrentAbsoluteTime(void);
|
|
|
|
|
1996-08-28 03:59:28 +02:00
|
|
|
/*
|
|
|
|
* getSystemTime --
|
1997-09-07 07:04:48 +02:00
|
|
|
* Returns system time.
|
1996-08-28 03:59:28 +02:00
|
|
|
*/
|
|
|
|
#define getSystemTime() \
|
1997-09-07 07:04:48 +02:00
|
|
|
((time_t) (time(0l)))
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* nabstime.c prototypes
|
1996-08-28 03:59:28 +02:00
|
|
|
*/
|
|
|
|
extern AbsoluteTime nabstimein(char *timestr);
|
1997-09-08 04:41:22 +02:00
|
|
|
extern char *nabstimeout(AbsoluteTime time);
|
1997-03-15 00:34:16 +01:00
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
extern bool abstimeeq(AbsoluteTime t1, AbsoluteTime t2);
|
|
|
|
extern bool abstimene(AbsoluteTime t1, AbsoluteTime t2);
|
|
|
|
extern bool abstimelt(AbsoluteTime t1, AbsoluteTime t2);
|
|
|
|
extern bool abstimegt(AbsoluteTime t1, AbsoluteTime t2);
|
|
|
|
extern bool abstimele(AbsoluteTime t1, AbsoluteTime t2);
|
|
|
|
extern bool abstimege(AbsoluteTime t1, AbsoluteTime t2);
|
|
|
|
extern bool abstime_finite(AbsoluteTime time);
|
1997-03-15 00:34:16 +01:00
|
|
|
|
1997-09-08 23:56:23 +02:00
|
|
|
extern AbsoluteTime datetime_abstime(DateTime *datetime);
|
From: Thomas Lockhart <Thomas.G.Lockhart@jpl.nasa.gov>
Subject: [HACKERS] More date time functions
Here are some additional patches mostly related to the date and time
data types. It includes some type conversion routines to move between
the different date types and some other date manipulation routines such
as date_part(units,datetime).
I noticed Edmund Mergl et al's neat trick for getting function overloading
for builtin functions, so started to use that for the date and time stuff.
Later, if someone figures out how to get function overloading directly
for internal C code, then we can move to that technique.
These patches include documentation updates (don't faint!) for the built-in
man page. Doesn't yet include mention of timestamp, since I don't know
much about it and since it may change a bit to become a _real_ ANSI timestamp
which would include parser support for the declaration syntax (what do you
think, Dan?).
The patches were developed on the 970330 release, but have been rebuilt
off of the 970402 release. The first patch below is to get libpq to compile,
on my Linux box, but is not related to the rest of the patches and you can
choose not to apply that one at this time. Thanks in advance, scrappy!
1997-04-02 20:36:24 +02:00
|
|
|
extern DateTime *abstime_datetime(AbsoluteTime abstime);
|
1997-03-25 09:11:24 +01:00
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
extern bool AbsoluteTimeIsBefore(AbsoluteTime time1, AbsoluteTime time2);
|
|
|
|
extern bool AbsoluteTimeIsAfter(AbsoluteTime time1, AbsoluteTime time2);
|
From: Thomas Lockhart <Thomas.G.Lockhart@jpl.nasa.gov>
Subject: [HACKERS] More date time functions
Here are some additional patches mostly related to the date and time
data types. It includes some type conversion routines to move between
the different date types and some other date manipulation routines such
as date_part(units,datetime).
I noticed Edmund Mergl et al's neat trick for getting function overloading
for builtin functions, so started to use that for the date and time stuff.
Later, if someone figures out how to get function overloading directly
for internal C code, then we can move to that technique.
These patches include documentation updates (don't faint!) for the built-in
man page. Doesn't yet include mention of timestamp, since I don't know
much about it and since it may change a bit to become a _real_ ANSI timestamp
which would include parser support for the declaration syntax (what do you
think, Dan?).
The patches were developed on the 970330 release, but have been rebuilt
off of the 970402 release. The first patch below is to get libpq to compile,
on my Linux box, but is not related to the rest of the patches and you can
choose not to apply that one at this time. Thanks in advance, scrappy!
1997-04-02 20:36:24 +02:00
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
extern void abstime2tm(AbsoluteTime time, int *tzp, struct tm * tm, char *tzn);
|
1996-08-28 03:59:28 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
#endif /* NABSTIME_H */
|