1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
From 70fe4e091eadb40a57b90c0d6345b7722b6817db Mon Sep 17 00:00:00 2001
From: Thijs <thijs@305.nl>
Date: Thu, 29 Aug 2019 16:55:46 +0200
Subject: [PATCH] Fixed issue with microseconds on php 7.3
---
.travis.yml | 1 +
tests/date_007.phpt | 2 +-
tests/date_008.phpt | 2 +-
tests/date_override_007.phpt | 2 +-
tests/date_override_008.phpt | 2 +-
tests/immutable_007.phpt | 2 +-
tests/immutable_008.phpt | 2 +-
tests/immutable_override_007.phpt | 2 +-
tests/immutable_override_008.phpt | 2 +-
timecop_php7.c | 21 +++++++++++++++------
10 files changed, 24 insertions(+), 14 deletions(-)
diff --git a/tests/date_007.phpt b/tests/date_007.phpt
index fe47ded..db490d8 100644
--- a/tests/date_007.phpt
+++ b/tests/date_007.phpt
@@ -58,7 +58,7 @@ string\(32\) "2010-09-02 03:04:05\.000000-07:00"
string\(32\) "2010-12-24 03:04:05\.000000-08:00"
string\(32\) "2010-01-02 05:00:00\.000000\+09:00"
string\(32\) "2010-01-02 00:00:59\.000000-08:00"
-string\(32\) "2010-01-02 03:04:05\.654321-08:00"
+string\(32\) "2010-01-02 (00|03):(00|04):(00|05)\.654321-08:00"
string\(32\) "2012-03-31 12:34:56\.000000-07:00"
string\(32\) "1970-01-01 12:34:56\.000000-08:00"
string\(32\) "1970-01-01 19:00:00\.000000-05:00"
diff --git a/tests/date_008.phpt b/tests/date_008.phpt
index 25ea7b1..851c953 100644
--- a/tests/date_008.phpt
+++ b/tests/date_008.phpt
@@ -59,7 +59,7 @@ string\(32\) "2010-09-02 03:04:05\.000000-07:00"
string\(32\) "2010-12-24 03:04:05\.000000-08:00"
string\(32\) "2010-01-02 05:00:00\.000000\+09:00"
string\(32\) "2010-01-02 00:00:59\.000000-08:00"
-string\(32\) "2010-01-02 03:04:05\.654321-08:00"
+string\(32\) "2010-01-02 (00|03):(00|04):(00|05)\.654321-08:00"
string\(32\) "2012-03-31 12:34:56\.000000-07:00"
string\(32\) "1970-01-01 12:34:56\.000000-08:00"
string\(32\) "1970-01-01 19:00:00\.000000-05:00"
diff --git a/tests/date_override_007.phpt b/tests/date_override_007.phpt
index 804a982..6dd8311 100644
--- a/tests/date_override_007.phpt
+++ b/tests/date_override_007.phpt
@@ -60,7 +60,7 @@ string\(32\) "2010-09-02 03:04:05\.000000-07:00"
string\(32\) "2010-12-24 03:04:05\.000000-08:00"
string\(32\) "2010-01-02 05:00:00\.000000\+09:00"
string\(32\) "2010-01-02 00:00:59\.000000-08:00"
-string\(32\) "2010-01-02 03:04:05\.654321-08:00"
+string\(32\) "2010-01-02 (00|03):(00|04):(00|05)\.654321-08:00"
string\(32\) "2012-03-31 12:34:56\.000000-07:00"
string\(32\) "1970-01-01 12:34:56\.000000-08:00"
string\(32\) "1970-01-01 19:00:00\.000000-05:00"
diff --git a/tests/date_override_008.phpt b/tests/date_override_008.phpt
index 9002b2f..8d38c04 100644
--- a/tests/date_override_008.phpt
+++ b/tests/date_override_008.phpt
@@ -61,7 +61,7 @@ string\(32\) "2010-09-02 03:04:05\.000000-07:00"
string\(32\) "2010-12-24 03:04:05\.000000-08:00"
string\(32\) "2010-01-02 05:00:00\.000000\+09:00"
string\(32\) "2010-01-02 00:00:59\.000000-08:00"
-string\(32\) "2010-01-02 03:04:05\.654321-08:00"
+string\(32\) "2010-01-02 (00|03):(00|04):(00|05)\.654321-08:00"
string\(32\) "2012-03-31 12:34:56\.000000-07:00"
string\(32\) "1970-01-01 12:34:56\.000000-08:00"
string\(32\) "1970-01-01 19:00:00\.000000-05:00"
diff --git a/tests/immutable_007.phpt b/tests/immutable_007.phpt
index 22d2742..3bcf5c0 100644
--- a/tests/immutable_007.phpt
+++ b/tests/immutable_007.phpt
@@ -58,7 +58,7 @@ string\(32\) "2010-09-02 03:04:05\.000000-07:00"
string\(32\) "2010-12-24 03:04:05\.000000-08:00"
string\(32\) "2010-01-02 05:00:00\.000000\+09:00"
string\(32\) "2010-01-02 00:00:59\.000000-08:00"
-string\(32\) "2010-01-02 03:04:05\.654321-08:00"
+string\(32\) "2010-01-02 (00|03):(00|04):(00|05)\.654321-08:00"
string\(32\) "2012-03-31 12:34:56\.000000-07:00"
string\(32\) "1970-01-01 12:34:56\.000000-08:00"
string\(32\) "1970-01-01 19:00:00\.000000-05:00"
diff --git a/tests/immutable_008.phpt b/tests/immutable_008.phpt
index fa82837..8fd738f 100644
--- a/tests/immutable_008.phpt
+++ b/tests/immutable_008.phpt
@@ -59,7 +59,7 @@ string\(32\) "2010-09-02 03:04:05\.000000-07:00"
string\(32\) "2010-12-24 03:04:05\.000000-08:00"
string\(32\) "2010-01-02 05:00:00\.000000\+09:00"
string\(32\) "2010-01-02 00:00:59\.000000-08:00"
-string\(32\) "2010-01-02 03:04:05\.654321-08:00"
+string\(32\) "2010-01-02 (00|03):(00|04):(00|05)\.654321-08:00"
string\(32\) "2012-03-31 12:34:56\.000000-07:00"
string\(32\) "1970-01-01 12:34:56\.000000-08:00"
string\(32\) "1970-01-01 19:00:00\.000000-05:00"
diff --git a/tests/immutable_override_007.phpt b/tests/immutable_override_007.phpt
index 1bb9992..7d26767 100644
--- a/tests/immutable_override_007.phpt
+++ b/tests/immutable_override_007.phpt
@@ -60,7 +60,7 @@ string\(32\) "2010-09-02 03:04:05\.000000-07:00"
string\(32\) "2010-12-24 03:04:05\.000000-08:00"
string\(32\) "2010-01-02 05:00:00\.000000\+09:00"
string\(32\) "2010-01-02 00:00:59\.000000-08:00"
-string\(32\) "2010-01-02 03:04:05\.654321-08:00"
+string\(32\) "2010-01-02 (00|03):(00|04):(00|05)\.654321-08:00"
string\(32\) "2012-03-31 12:34:56\.000000-07:00"
string\(32\) "1970-01-01 12:34:56\.000000-08:00"
string\(32\) "1970-01-01 19:00:00\.000000-05:00"
diff --git a/tests/immutable_override_008.phpt b/tests/immutable_override_008.phpt
index 8ecec38..1c74cc9 100644
--- a/tests/immutable_override_008.phpt
+++ b/tests/immutable_override_008.phpt
@@ -61,7 +61,7 @@ string\(32\) "2010-09-02 03:04:05\.000000-07:00"
string\(32\) "2010-12-24 03:04:05\.000000-08:00"
string\(32\) "2010-01-02 05:00:00\.000000\+09:00"
string\(32\) "2010-01-02 00:00:59\.000000-08:00"
-string\(32\) "2010-01-02 03:04:05\.654321-08:00"
+string\(32\) "2010-01-02 (00|03):(00|04):(00|05)\.654321-08:00"
string\(32\) "2012-03-31 12:34:56\.000000-07:00"
string\(32\) "1970-01-01 12:34:56\.000000-08:00"
string\(32\) "1970-01-01 19:00:00\.000000-05:00"
diff --git a/timecop_php7.c b/timecop_php7.c
index 8d7faec..93c51e6 100644
--- a/timecop_php7.c
+++ b/timecop_php7.c
@@ -1457,7 +1457,8 @@ static void _timecop_date_create_from_format(INTERNAL_FUNCTION_PARAMETERS, int i
memchr(orig_format_str, 'G', orig_format_len) ||
memchr(orig_format_str, 'H', orig_format_len) ||
memchr(orig_format_str, 'i', orig_format_len) ||
- memchr(orig_format_str, 's', orig_format_len)) {
+ memchr(orig_format_str, 's', orig_format_len)
+ ) {
ZVAL_STRING(&fixed_format, "Y-m-d ??:??:??.??????");
} else if (memchr(orig_format_str, 'Y', orig_format_len) ||
memchr(orig_format_str, 'y', orig_format_len) ||
@@ -1471,12 +1472,20 @@ static void _timecop_date_create_from_format(INTERNAL_FUNCTION_PARAMETERS, int i
memchr(orig_format_str, 'l', orig_format_len) ||
memchr(orig_format_str, 'U', orig_format_len)) {
ZVAL_STRING(&fixed_format, "Y-m-d H:i:s.??????");
+ } else if (memchr(orig_format_str, 'u', orig_format_len)) {
+ #if PHP_VERSION_ID >= 70300
+ ZVAL_STRING(&fixed_format, "Y-m-d ??:??:??.??????");
+ #elif PHP_VERSION_ID >= 70100
+ ZVAL_STRING(&fixed_format, "Y-m-d H:i:s.u");
+ #else
+ ZVAL_STRING(&fixed_format, "Y-m-d H:i:s.??????");
+ #endif
} else {
-#if PHP_VERSION_ID >= 70100
- ZVAL_STRING(&fixed_format, "Y-m-d H:i:s.u");
-#else
- ZVAL_STRING(&fixed_format, "Y-m-d H:i:s.??????");
-#endif
+ #if PHP_VERSION_ID >= 70100
+ ZVAL_STRING(&fixed_format, "Y-m-d H:i:s.u");
+ #else
+ ZVAL_STRING(&fixed_format, "Y-m-d H:i:s.??????");
+ #endif
}
ZVAL_STRING(&tmp, "%s %s");
|