20
20
#include "php.h"
21
21
#include "php_calendar.h"
22
22
#include "sdncal.h"
23
+ #include "../date/lib/timelib.h"
23
24
#include <time.h>
24
25
25
26
/**
@@ -30,7 +31,7 @@ static void _cal_easter(INTERNAL_FUNCTION_PARAMETERS, bool gm)
30
31
{
31
32
/* based on code by Simon Kershaw, <[email protected] > */
32
33
33
- struct tm te ;
34
+ timelib_time * t ;
34
35
zend_long year , golden , solar , lunar , pfm , dom , tmp , easter , result ;
35
36
zend_long method = CAL_EASTER_DEFAULT ;
36
37
const zend_long max_year = (zend_long )(ZEND_LONG_MAX / 5 ) * 4 ;
@@ -59,7 +60,7 @@ static void _cal_easter(INTERNAL_FUNCTION_PARAMETERS, bool gm)
59
60
RETURN_THROWS ();
60
61
}
61
62
62
- #ifdef ZEND_ENABLE_ZVAL_LONG64
63
+ #ifdef ZEND_ENABLE_ZVAL_LONG64
63
64
/* Compiling for 64bit, allow years between 1970 and 2.000.000.000 */
64
65
if (gm && year < 1970 ) {
65
66
/* timestamps only start after 1970 */
@@ -72,13 +73,13 @@ static void _cal_easter(INTERNAL_FUNCTION_PARAMETERS, bool gm)
72
73
zend_argument_value_error (1 , "must be a year before 2.000.000.000 (inclusive)" );
73
74
RETURN_THROWS ();
74
75
}
75
- #else
76
+ #else
76
77
/* Compiling for 32bit, allow years between 1970 and 2037 */
77
78
if (gm && (year < 1970 || year > 2037 )) {
78
79
zend_argument_value_error (1 , "must be between 1970 and 2037 (inclusive)" );
79
80
RETURN_THROWS ();
80
81
}
81
- #endif
82
+ #endif
82
83
83
84
84
85
golden = (year % 19 ) + 1 ; /* the Golden number */
@@ -123,20 +124,26 @@ static void _cal_easter(INTERNAL_FUNCTION_PARAMETERS, bool gm)
123
124
easter = pfm + tmp + 1 ; /* Easter as the number of days after 21st March */
124
125
125
126
if (gm ) { /* return a timestamp */
126
- te .tm_isdst = -1 ;
127
- te .tm_year = year - 1900 ;
128
- te .tm_sec = 0 ;
129
- te .tm_min = 0 ;
130
- te .tm_hour = 0 ;
127
+ t = timelib_time_ctor ();
128
+ t -> us = 0 ;
129
+ t -> s = 0 ;
130
+ t -> i = 0 ;
131
+ t -> h = 0 ;
132
+ t -> y = year ;
133
+ t -> z = 0 ;
134
+ t -> dst = -1 ;
131
135
132
136
if (easter < 11 ) {
133
- te . tm_mon = 2 ; /* March */
134
- te . tm_mday = easter + 21 ;
137
+ t -> m = 3 ;
138
+ t -> d = easter + 21 ;
135
139
} else {
136
- te . tm_mon = 3 ; /* April */
137
- te . tm_mday = easter - 10 ;
140
+ t -> m = 4 ;
141
+ t -> d = easter - 10 ;
138
142
}
139
- result = mktime (& te );
143
+
144
+ timelib_update_ts (t , NULL );
145
+ result = t -> sse ;
146
+ timelib_time_dtor (t );
140
147
} else { /* return the days after March 21 */
141
148
result = easter ;
142
149
}
0 commit comments