Header And Logo

PostgreSQL
| The world's most advanced open source database.

pgtime.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * pgtime.h
00004  *    PostgreSQL internal timezone library
00005  *
00006  * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
00007  *
00008  * IDENTIFICATION
00009  *    src/include/pgtime.h
00010  *
00011  *-------------------------------------------------------------------------
00012  */
00013 #ifndef _PGTIME_H
00014 #define _PGTIME_H
00015 
00016 
00017 /*
00018  * The API of this library is generally similar to the corresponding
00019  * C library functions, except that we use pg_time_t which (we hope) is
00020  * 64 bits wide, and which is most definitely signed not unsigned.
00021  */
00022 
00023 typedef int64 pg_time_t;
00024 
00025 struct pg_tm
00026 {
00027     int         tm_sec;
00028     int         tm_min;
00029     int         tm_hour;
00030     int         tm_mday;
00031     int         tm_mon;         /* origin 0, not 1 */
00032     int         tm_year;        /* relative to 1900 */
00033     int         tm_wday;
00034     int         tm_yday;
00035     int         tm_isdst;
00036     long int    tm_gmtoff;
00037     const char *tm_zone;
00038 };
00039 
00040 typedef struct pg_tz pg_tz;
00041 typedef struct pg_tzenum pg_tzenum;
00042 
00043 /* Maximum length of a timezone name (not including trailing null) */
00044 #define TZ_STRLEN_MAX 255
00045 
00046 /* these functions are in localtime.c */
00047 
00048 extern struct pg_tm *pg_localtime(const pg_time_t *timep, const pg_tz *tz);
00049 extern struct pg_tm *pg_gmtime(const pg_time_t *timep);
00050 extern int pg_next_dst_boundary(const pg_time_t *timep,
00051                      long int *before_gmtoff,
00052                      int *before_isdst,
00053                      pg_time_t *boundary,
00054                      long int *after_gmtoff,
00055                      int *after_isdst,
00056                      const pg_tz *tz);
00057 extern size_t pg_strftime(char *s, size_t max, const char *format,
00058             const struct pg_tm * tm);
00059 
00060 extern bool pg_get_timezone_offset(const pg_tz *tz, long int *gmtoff);
00061 extern const char *pg_get_timezone_name(pg_tz *tz);
00062 extern bool pg_tz_acceptable(pg_tz *tz);
00063 
00064 /* these functions and variables are in pgtz.c */
00065 
00066 extern pg_tz *session_timezone;
00067 extern pg_tz *log_timezone;
00068 
00069 extern void pg_timezone_initialize(void);
00070 extern pg_tz *pg_tzset(const char *tzname);
00071 
00072 extern pg_tzenum *pg_tzenumerate_start(void);
00073 extern pg_tz *pg_tzenumerate_next(pg_tzenum *dir);
00074 extern void pg_tzenumerate_end(pg_tzenum *dir);
00075 
00076 #endif   /* _PGTIME_H */