PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
pgtime.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * pgtime.h
4  * PostgreSQL internal timezone library
5  *
6  * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
7  *
8  * IDENTIFICATION
9  * src/include/pgtime.h
10  *
11  *-------------------------------------------------------------------------
12  */
13 #ifndef _PGTIME_H
14 #define _PGTIME_H
15 
16 
17 /*
18  * The API of this library is generally similar to the corresponding
19  * C library functions, except that we use pg_time_t which (we hope) is
20  * 64 bits wide, and which is most definitely signed not unsigned.
21  */
22 
23 typedef int64 pg_time_t;
24 
25 struct pg_tm
26 {
27  int tm_sec;
28  int tm_min;
29  int tm_hour;
30  int tm_mday;
31  int tm_mon; /* origin 1, not 0! */
32  int tm_year; /* relative to 1900 */
33  int tm_wday;
34  int tm_yday;
35  int tm_isdst;
36  long int tm_gmtoff;
37  const char *tm_zone;
38 };
39 
40 typedef struct pg_tz pg_tz;
41 typedef struct pg_tzenum pg_tzenum;
42 
43 /* Maximum length of a timezone name (not including trailing null) */
44 #define TZ_STRLEN_MAX 255
45 
46 /* these functions are in localtime.c */
47 
48 extern struct pg_tm *pg_localtime(const pg_time_t *timep, const pg_tz *tz);
49 extern struct pg_tm *pg_gmtime(const pg_time_t *timep);
50 extern int pg_next_dst_boundary(const pg_time_t *timep,
51  long int *before_gmtoff,
52  int *before_isdst,
53  pg_time_t *boundary,
54  long int *after_gmtoff,
55  int *after_isdst,
56  const pg_tz *tz);
57 extern bool pg_interpret_timezone_abbrev(const char *abbrev,
58  const pg_time_t *timep,
59  long int *gmtoff,
60  int *isdst,
61  const pg_tz *tz);
62 extern bool pg_get_timezone_offset(const pg_tz *tz, long int *gmtoff);
63 extern const char *pg_get_timezone_name(pg_tz *tz);
64 extern bool pg_tz_acceptable(pg_tz *tz);
65 
66 /* these functions are in strftime.c */
67 
68 extern size_t pg_strftime(char *s, size_t max, const char *format,
69  const struct pg_tm * tm);
70 
71 /* these functions and variables are in pgtz.c */
72 
73 extern pg_tz *session_timezone;
74 extern pg_tz *log_timezone;
75 
76 extern void pg_timezone_initialize(void);
77 extern pg_tz *pg_tzset(const char *tzname);
78 extern pg_tz *pg_tzset_offset(long gmtoffset);
79 
80 extern pg_tzenum *pg_tzenumerate_start(void);
81 extern pg_tz *pg_tzenumerate_next(pg_tzenum *dir);
82 extern void pg_tzenumerate_end(pg_tzenum *dir);
83 
84 #endif /* _PGTIME_H */
size_t pg_strftime(char *s, size_t max, const char *format, const struct pg_tm *tm)
Definition: strftime.c:124
int64 pg_time_t
Definition: pgtime.h:23
int tm_wday
Definition: pgtime.h:33
int pg_next_dst_boundary(const pg_time_t *timep, long int *before_gmtoff, int *before_isdst, pg_time_t *boundary, long int *after_gmtoff, int *after_isdst, const pg_tz *tz)
Definition: localtime.c:1505
struct pg_tm * pg_gmtime(const pg_time_t *timep)
Definition: localtime.c:1295
int tm_isdst
Definition: pgtime.h:35
int tm_hour
Definition: pgtime.h:29
void pg_tzenumerate_end(pg_tzenum *dir)
Definition: pgtz.c:398
long int tm_gmtoff
Definition: pgtime.h:36
Definition: pgtime.h:25
static struct pg_tm tm
Definition: localtime.c:103
pg_tz * log_timezone
Definition: pgtz.c:30
pg_tz * pg_tzset(const char *tzname)
Definition: pgtz.c:218
void pg_timezone_initialize(void)
Definition: pgtz.c:345
bool pg_interpret_timezone_abbrev(const char *abbrev, const pg_time_t *timep, long int *gmtoff, int *isdst, const pg_tz *tz)
Definition: localtime.c:1652
const char * pg_get_timezone_name(pg_tz *tz)
Definition: localtime.c:1770
int tm_mday
Definition: pgtime.h:30
int tm_mon
Definition: pgtime.h:31
const char * tm_zone
Definition: pgtime.h:37
pg_tz * pg_tzset_offset(long gmtoffset)
Definition: pgtz.c:304
bool pg_tz_acceptable(pg_tz *tz)
Definition: localtime.c:1785
Definition: pgtz.h:59
pg_tzenum * pg_tzenumerate_start(void)
Definition: pgtz.c:381
struct pg_tm * pg_localtime(const pg_time_t *timep, const pg_tz *tz)
Definition: localtime.c:1254
pg_tz * pg_tzenumerate_next(pg_tzenum *dir)
Definition: pgtz.c:410
int tm_year
Definition: pgtime.h:32
int tm_yday
Definition: pgtime.h:34
pg_tz * session_timezone
Definition: pgtz.c:27
static char format
Definition: pg_basebackup.c:83
bool pg_get_timezone_offset(const pg_tz *tz, long int *gmtoff)
Definition: localtime.c:1746
int tm_sec
Definition: pgtime.h:27
int tm_min
Definition: pgtime.h:28