summaryrefslogtreecommitdiff
path: root/src/include/pgtime.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-05-21 05:08:06 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-05-21 05:08:06 +0000
commit63bd0db12199c5df043e1dea0f2b574f622b3a4c (patch)
treedbafdb6e4541162ad369dbfeca24cbd62aefddcc /src/include/pgtime.h
parent260b513fc37b6ed2df51586c487d0832b89d0d70 (diff)
downloadpostgresql-63bd0db12199c5df043e1dea0f2b574f622b3a4c.tar.gz
Integrate src/timezone library for all platforms. There is more we can
and should do now that we control our own destiny for timezone handling, but this commit gets the bulk of the picayune diffs in place. Magnus Hagander and Tom Lane.
Diffstat (limited to 'src/include/pgtime.h')
-rw-r--r--src/include/pgtime.h73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/include/pgtime.h b/src/include/pgtime.h
new file mode 100644
index 0000000000..8493c8c6f7
--- /dev/null
+++ b/src/include/pgtime.h
@@ -0,0 +1,73 @@
+/*-------------------------------------------------------------------------
+ *
+ * pgtime.h
+ * PostgreSQL internal timezone library
+ *
+ * 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 $
+ *
+ *-------------------------------------------------------------------------
+ */
+#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"
+ */
+#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>
+
+/*
+ * 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_wday;
+ int tm_yday;
+ int tm_isdst;
+ long int tm_gmtoff;
+ 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 bool pg_tzset(const char *tzname);
+extern size_t pg_strftime(char *s, size_t max, const char *format,
+ const struct pg_tm *tm);
+extern void pg_timezone_initialize(void);
+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 */