summaryrefslogtreecommitdiff
path: root/src/include/pgtime.h
diff options
context:
space:
mode:
authorTom Lane2004-06-03 02:08:07 +0000
committerTom Lane2004-06-03 02:08:07 +0000
commit921d749bd4c34c3349f1c254d5faa2f1cec03911 (patch)
treec349959cb92495a8231020062fa46ac1c2b57afd /src/include/pgtime.h
parent473ac70acae41c5f1fecbb0b57e9f5be5b26ab68 (diff)
Adjust our timezone library to use pg_time_t (typedef'd as int64) in
place of time_t, as per prior discussion. The behavior does not change on machines without a 64-bit-int type, but on machines with one, which is most, we are rid of the bizarre boundary behavior at the edges of the 32-bit-time_t range (1901 and 2038). The system will now treat times over the full supported timestamp range as being in your local time zone. It may seem a little bizarre to consider that times in 4000 BC are PST or EST, but this is surely at least as reasonable as propagating Gregorian calendar rules back that far. I did not modify the format of the zic timezone database files, which means that for the moment the system will not know about daylight-savings periods outside the range 1901-2038. Given the way the files are set up, it's not a simple decision like 'widen to 64 bits'; we have to actually think about the range of years that need to be supported. We should probably inquire what the plans of the upstream zic people are before making any decisions of our own.
Diffstat (limited to 'src/include/pgtime.h')
-rw-r--r--src/include/pgtime.h44
1 files changed, 10 insertions, 34 deletions
diff --git a/src/include/pgtime.h b/src/include/pgtime.h
index 8493c8c6f7..e772d76bd7 100644
--- a/src/include/pgtime.h
+++ b/src/include/pgtime.h
@@ -6,50 +6,29 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/include/pgtime.h,v 1.1 2004/05/21 05:08:03 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/pgtime.h,v 1.2 2004/06/03 02:08:06 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef _PGTIME_H
#define _PGTIME_H
-#ifdef FRONTEND
-/* Don't mess with anything for the frontends */
-#include <time.h>
-
-#else
-
-/*
- * Redefine functions and defines we implement, so we cause an
- * error if someone tries to use the "base functions"
+/*
+ * The API of this library is generally similar to the corresponding
+ * C library functions, except that we use pg_time_t which (we hope) is
+ * 64 bits wide, and which is most definitely signed not unsigned.
*/
-#ifndef NO_REDEFINE_TIMEFUNCS
-#define localtime DONOTUSETHIS_localtime
-#define gmtime DONOTUSETHIS_gmtime
-#define asctime DONOTUSETHIS_asctime
-#define ctime DONOTUSETHIS_ctime
-#define tzset DONOTUSETHIS_tzset
-#define mktime DONOTUSETHIS_mktime
-#define tzname DONOTUSETHIS_tzname
-#define daylight DONOTUSETHIS_daylight
-#define strftime DONOTUSETHIS_strftime
-#endif
-/* Then pull in default declarations, particularly time_t */
-#include <time.h>
+typedef int64 pg_time_t;
-/*
- * Now define prototype for our own timezone implementation
- * structs and functions.
- */
struct pg_tm {
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
- int tm_mon;
- int tm_year;
+ int tm_mon; /* origin 0, not 1 */
+ int tm_year; /* relative to 1900 */
int tm_wday;
int tm_yday;
int tm_isdst;
@@ -57,9 +36,8 @@ struct pg_tm {
const char *tm_zone;
};
-extern struct pg_tm *pg_localtime(const time_t *);
-extern struct pg_tm *pg_gmtime(const time_t *);
-extern time_t pg_mktime(struct pg_tm *);
+extern struct pg_tm *pg_localtime(const pg_time_t *);
+extern struct pg_tm *pg_gmtime(const pg_time_t *);
extern bool pg_tzset(const char *tzname);
extern size_t pg_strftime(char *s, size_t max, const char *format,
const struct pg_tm *tm);
@@ -68,6 +46,4 @@ extern bool tz_acceptable(void);
extern const char *select_default_timezone(void);
extern const char *pg_get_current_timezone(void);
-#endif /* FRONTEND */
-
#endif /* _PGTIME_H */