pgtime.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*-------------------------------------------------------------------------
  2. *
  3. * pgtime.h
  4. * PostgreSQL internal timezone library
  5. *
  6. * Portions Copyright (c) 1996-2016, 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. * The API of this library is generally similar to the corresponding
  17. * C library functions, except that we use pg_time_t which (we hope) is
  18. * 64 bits wide, and which is most definitely signed not unsigned.
  19. */
  20. typedef int64 pg_time_t;
  21. struct pg_tm
  22. {
  23. int tm_sec;
  24. int tm_min;
  25. int tm_hour;
  26. int tm_mday;
  27. int tm_mon; /* origin 0, not 1 */
  28. int tm_year; /* relative to 1900 */
  29. int tm_wday;
  30. int tm_yday;
  31. int tm_isdst;
  32. long int tm_gmtoff;
  33. const char *tm_zone;
  34. };
  35. typedef struct pg_tz pg_tz;
  36. typedef struct pg_tzenum pg_tzenum;
  37. /* Maximum length of a timezone name (not including trailing null) */
  38. #define TZ_STRLEN_MAX 255
  39. /* these functions are in localtime.c */
  40. extern struct pg_tm *pg_localtime(const pg_time_t *timep, const pg_tz *tz);
  41. extern struct pg_tm *pg_gmtime(const pg_time_t *timep);
  42. extern int pg_next_dst_boundary(const pg_time_t *timep,
  43. long int *before_gmtoff,
  44. int *before_isdst,
  45. pg_time_t *boundary,
  46. long int *after_gmtoff,
  47. int *after_isdst,
  48. const pg_tz *tz);
  49. extern bool pg_interpret_timezone_abbrev(const char *abbrev,
  50. const pg_time_t *timep,
  51. long int *gmtoff,
  52. int *isdst,
  53. const pg_tz *tz);
  54. extern bool pg_get_timezone_offset(const pg_tz *tz, long int *gmtoff);
  55. extern const char *pg_get_timezone_name(pg_tz *tz);
  56. extern bool pg_tz_acceptable(pg_tz *tz);
  57. /* these functions are in strftime.c */
  58. extern size_t pg_strftime(char *s, size_t max, const char *format,
  59. const struct pg_tm * tm);
  60. /* these functions and variables are in pgtz.c */
  61. extern pg_tz *session_timezone;
  62. extern pg_tz *log_timezone;
  63. extern void pg_timezone_initialize(void);
  64. extern pg_tz *pg_tzset(const char *tzname);
  65. extern pg_tz *pg_tzset_offset(long gmtoffset);
  66. extern pg_tzenum *pg_tzenumerate_start(void);
  67. extern pg_tz *pg_tzenumerate_next(pg_tzenum *dir);
  68. extern void pg_tzenumerate_end(pg_tzenum *dir);
  69. #endif /* _PGTIME_H */