php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
timelib_private.h
Go to the documentation of this file.
1/*
2 * The MIT License (MIT)
3 *
4 * Copyright (c) 2015-2019 Derick Rethans
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24
25#ifndef __TIMELIB_PRIVATE_H__
26#define __TIMELIB_PRIVATE_H__
27
28#ifdef HAVE_TIMELIB_CONFIG_H
29# include "timelib_config.h"
30#endif
31
32#ifdef HAVE_SYS_TIME_H
33# include <sys/time.h>
34#endif
35
36#ifdef _WIN32
37# ifdef HAVE_WINSOCK2_H
38# include <winsock2.h>
39# endif
40#endif
41
42#include <string.h>
43
44#ifdef HAVE_SYS_TYPES_H
45#include <sys/types.h>
46#endif
47
48#if defined(HAVE_STDINT_H)
49# include <stdint.h>
50#endif
51
52#if HAVE_UNISTD_H
53# include <unistd.h>
54#endif
55
56#if HAVE_IO_H
57# include <io.h>
58#endif
59
60#if HAVE_DIRENT_H
61# include <dirent.h>
62#endif
63
64#include <stdio.h>
65#include <limits.h>
66
67#define TIMELIB_SECOND 1
68#define TIMELIB_MINUTE 2
69#define TIMELIB_HOUR 3
70#define TIMELIB_DAY 4
71#define TIMELIB_MONTH 5
72#define TIMELIB_YEAR 6
73#define TIMELIB_WEEKDAY 7
74#define TIMELIB_SPECIAL 8
75#define TIMELIB_MICROSEC 9
76
77#define TIMELIB_SPECIAL_WEEKDAY 0x01
78#define TIMELIB_SPECIAL_DAY_OF_WEEK_IN_MONTH 0x02
79#define TIMELIB_SPECIAL_LAST_DAY_OF_WEEK_IN_MONTH 0x03
80
81#define TIMELIB_SPECIAL_FIRST_DAY_OF_MONTH 0x01
82#define TIMELIB_SPECIAL_LAST_DAY_OF_MONTH 0x02
83
84#define TIMELIB_TIME_PART_DONT_KEEP 0x00
85#define TIMELIB_TIME_PART_KEEP 0x01
86
87#define MINS_PER_HOUR 60
88#define SECS_PER_ERA TIMELIB_LL_CONST(12622780800)
89#define SECS_PER_DAY 86400
90#define SECS_PER_HOUR 3600
91#define USECS_PER_HOUR TIMELIB_LL_CONST(3600000000)
92
93#define DAYS_PER_WEEK 7
94#define DAYS_PER_YEAR 365
95#define DAYS_PER_LYEAR 366
96#define MONTHS_PER_YEAR 12
97/* 400*365 days + 97 leap days */
98#define DAYS_PER_ERA 146097
99#define YEARS_PER_ERA 400
100#define HINNANT_EPOCH_SHIFT 719468 /* 0000-03-01 instead of 1970-01-01 */
101
102#define TIMELIB_TZINFO_PHP 0x01
103#define TIMELIB_TZINFO_ZONEINFO 0x02
104
105#define timelib_is_leap(y) ((y) % 4 == 0 && ((y) % 100 != 0 || (y) % 400 == 0))
106
107#define TIMELIB_DEBUG(s) if (0) { s }
108
109#define TIMELIB_TIME_FREE(m) \
110 if (m) { \
111 timelib_free(m); \
112 m = NULL; \
113 }
114
115#if defined (__GNUC__)
116# define TIMELIB_GNUC_CHECK_VERSION(major, minor) \
117 ((__GNUC__ > (major)) || \
118 ((__GNUC__ == (major)) && (__GNUC_MINOR__ >= (minor))))
119#else
120# define TIMELIB_GNUC_CHECK_VERSION(major, minor) 0
121#endif
122
123#if TIMELIB_GNUC_CHECK_VERSION(7, 0)
124# define TIMELIB_BREAK_INTENTIONALLY_MISSING __attribute__ ((fallthrough));
125#else
126# define TIMELIB_BREAK_INTENTIONALLY_MISSING
127#endif
128
129#if defined(__has_builtin)
130# if __has_builtin(__builtin_saddll_overflow)
131# define TIMELIB_HAVE_BUILTIN_SADDLL_OVERFLOW 1
132# endif
133#endif
134
135#ifndef TIMELIB_HAVE_BUILTIN_SADDLL_OVERFLOW
136# define TIMELIB_HAVE_BUILTIN_SADDLL_OVERFLOW 0
137#endif
139{
140 int32_t offset;
141 int isdst;
142 unsigned int abbr_idx;
143
144 unsigned int isstdcnt;
145 unsigned int isgmtcnt;
146};
147
149{
150 int64_t trans;
151 int32_t offset;
152};
153
154
155#ifndef LONG_MAX
156#define LONG_MAX 2147483647L
157#endif
158
159#ifndef LONG_MIN
160#define LONG_MIN (- LONG_MAX - 1)
161#endif
162
163#ifdef __cplusplus
164extern "C" {
165#endif
166
167/* From unixtime2tm.c */
169
170/* From parse_posix.c */
173
174/* From parse_tz.c */
175void timelib_time_tz_abbr_update(timelib_time* tm, const char* tz_abbr);
177
178/* From timelib.c */
179int timelib_strcasecmp(const char *s1, const char *s2);
180int timelib_strncasecmp(const char *s1, const char *s2, size_t n);
181
182#ifdef __cplusplus
183} /* extern "C" */
184#endif
185
186#endif
zend_long n
Definition ffi.c:4979
localtime(?int $timestamp=null, bool $associative=false)
int32_t offset
int64_t trans
int32_t offset
unsigned int isgmtcnt
unsigned int abbr_idx
unsigned int isstdcnt
struct _timelib_time timelib_time
struct _ttinfo ttinfo
Definition timelib.h:140
signed long long timelib_sll
Definition timelib.h:136
struct _timelib_tzinfo timelib_tzinfo
int timelib_strncasecmp(const char *s1, const char *s2, size_t n)
Definition timelib.c:280
ttinfo * timelib_fetch_posix_timezone_offset(timelib_tzinfo *tz, timelib_sll ts, timelib_sll *transition_time)
timelib_sll timelib_ts_at_start_of_year(timelib_sll year)
int timelib_strcasecmp(const char *s1, const char *s2)
Definition timelib.c:257
void timelib_time_tz_abbr_update(timelib_time *tm, const char *tz_abbr)
Definition timelib.c:121
int timelib_apply_localtime(timelib_time *t, unsigned int localtime)
ttinfo * timelib_fetch_timezone_offset(timelib_tzinfo *tz, timelib_sll ts, timelib_sll *transition_time)
Definition parse_tz.c:790