Commit graph

960 commits

Author SHA1 Message Date
Derick Rethans
8b2ee5388c Add DateTime/DateTimeImmutable's __serialize and __unserialize methods 2022-04-29 09:44:27 +01:00
Derick Rethans
36486106d9 Merge branch 'PHP-8.1' 2022-04-26 17:58:01 +01:00
Derick Rethans
97ffd75b13 Merge branch 'PHP-8.0' into PHP-8.1 2022-04-26 17:57:55 +01:00
Derick Rethans
b461c4673b Use the new RETURN_THROWS() instead of just returning NULL 2022-04-26 17:57:47 +01:00
Derick Rethans
a7eda3d548 Merge branch 'PHP-8.1' 2022-04-26 16:45:07 +01:00
Derick Rethans
bc43e69822 Merge branch 'PHP-8.0' into PHP-8.1 2022-04-26 16:45:01 +01:00
Derick Rethans
87f341b1c2 Return early when the timezone info is NULL.
The guess_timezone function does throw an error, but throwing an error doesn't
immediate make the PHP_FUNCTION return.

This check is really only necessary for distributions that patch PHP's timelib
to use system tzdata, but not correct enough to account for their
implementation to guarantee to return a timezone.
2022-04-26 16:43:30 +01:00
Derick Rethans
731e3f6c96 Merge branch 'PHP-8.1' 2022-04-14 10:32:25 +01:00
Derick Rethans
ec0771c03f Merge branch 'PHP-8.0' into PHP-8.1 2022-04-14 10:32:21 +01:00
Derick Rethans
e38d300a70 Refactor code to avoid duplication 2022-04-14 10:32:10 +01:00
Cody Mann
24085d0192 style/readability updates 2022-04-14 10:22:00 +01:00
Cody Mann
287c8a86b4 GH-7979: iterator advances when checking if valid 2022-04-14 10:22:00 +01:00
Derick Rethans
cd6c338c89 Merge branch 'PHP-8.1' 2022-04-01 13:28:13 +01:00
Derick Rethans
e6c4988187 Fixed #7752, #8101, #81660: DateTimeZone::getTransitions() returns insufficient data 2022-04-01 13:28:05 +01:00
Christoph M. Becker
b7d90f09d4
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix #81500: Interval serialization regression since 7.3.14 / 7.4.2
2021-10-15 19:14:00 +02:00
Christoph M. Becker
2e65c8e581
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix #81500: Interval serialization regression since 7.3.14 / 7.4.2
2021-10-15 19:13:38 +02:00
Christoph M. Becker
fc886694d3
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81500: Interval serialization regression since 7.3.14 / 7.4.2
2021-10-15 19:11:26 +02:00
Christoph M. Becker
866adb122a
Fix #81500: Interval serialization regression since 7.3.14 / 7.4.2
While it may not be desired, `DateInterval::$f` supports negative
values, at least with regard to calculations.  We still need to guard
from assigning double values which are out of range for signed 64bit
integers (which would be undefined behavior).  zend_dval_to_lval() does
this by returning `0` instead of triggering UB.  This way we can avoid
setting the invalid marker, which doesn't work as expected anyway.

We must not do that only for unserialization, but also when the property
is set in the first place.

We need to adapt some of the existing tests wrt. this behavior.  In
particular, we check for an arbitrary value in bug79015.phpt, to cater
to differences between 32bit and 64bit architectures.

Closes GH-7575.
2021-10-15 19:08:07 +02:00
Derick Rethans
0d6b8bbfcd Merge branch 'PHP-8.1' 2021-10-05 15:23:05 +01:00
Derick Rethans
68b874d10d Fixed bug #81504: Incorrect timezone transition details for POSIX data 2021-10-05 15:22:55 +01:00
George Peter Banyard
0663c64f41
Voidify php_date_interval_initialize_from_hash() 2021-09-29 17:15:50 +01:00
George Peter Banyard
492980c540
Use bool/zend_result instead of int in Date extension 2021-09-29 17:15:50 +01:00
Nikita Popov
9d8f97d58d Revert "Fix DATE_FORMAT_COOKIE definition"
This reverts commit ac34648cf6.

As pointed out on GH-6783, the new format doesn't match any of
the specified formats. Previously the constant generated

    Thursday, 14-Jul-2005 22:30:41 BST

which is obsolete. Now it generates

    Thu, 14-Jul-2005 22:30:41 BST

which is not specified at all. The correct version would be:

    Thu, 14 Jul 2005 22:30:41 BST

Reverting the change for now.
2021-09-29 09:26:40 +02:00
Mahmood Dhia
ac34648cf6 Fix DATE_FORMAT_COOKIE definition
In all of http://curl.haxx.se/rfc/cookie_spec.html,
https://docs.microsoft.com/de-de/windows/win32/wininet/http-cookies
and https://tools.ietf.org/html/rfc7234#section-5.3 the cookie
datetime is specified as Mon, DD-Mon-YYYY HH:MM:SS GMT. However,
the current definition returns Monday, DD-Mon-YYY HH:MM:SS GMT.
Therefore, the "l" in "l, d-M-Y H:i:s T" must be changed to "D".

Closes GH-6783.
2021-09-23 16:01:04 +02:00
Derick Rethans
d9c8e5a42e Fixed bug #80963: DateTimeZone::getTransitions() truncated 2021-08-08 17:27:21 +01:00
Derick Rethans
84008782d3 Merge branch 'PHP-8.0' 2021-07-19 15:08:21 +01:00
Derick Rethans
9d0fb10823 Merge branch 'PHP-7.4' into PHP-8.0 2021-07-19 15:08:09 +01:00
Derick Rethans
26b1572d37 Move date timezone cache destruction to post deactivate
Some extensions try to use the date features in their own shutdown,
most notably some logging functions. Because of that, move the
cache tear down until after these resources have been cleaned up.
2021-07-19 15:07:01 +01:00
Patrick Allaert
aff365871a Fixed some spaces used instead of tabs 2021-06-29 11:30:26 +02:00
George Peter Banyard
2f1d0f2bc3
Throw directly instead of replacing error handler in ext/date (#6954) 2021-05-07 11:10:39 +01:00
Nikita Popov
3b3f6de782 Use zend_string_concat3 in one place
A bit nicer than snprintf + passing the same length around three
times.
2021-05-07 10:43:40 +02:00
George Peter Banyard
2cd5a200f5
Refactor php_date_initialize_from_hash()
Use early returns
Formalize return type to bool
2021-05-06 21:48:52 +01:00
KsaR
01b3fc03c3
Update http->https in license (#6945)
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
2021-05-06 12:16:35 +02:00
George Peter Banyard
5caaf40b43
Introduce pseudo-keyword ZEND_FALLTHROUGH
And use it instead of comments
2021-04-07 00:46:29 +01:00
Derick Rethans
091c0920b9 Upgrade timelib to 2021.03 and fix many date/time issues 2021-04-06 20:50:32 +01:00
George Peter Banyard
6acb079906 Use zend_string_equals() API instead of strcmp() in Date extension 2021-03-17 16:36:16 +00:00
Dmitry Stogov
b4e9b18463 Avoid useless date conversion 2021-03-04 12:27:31 +03:00
Máté Kocsis
5f21062054
Generate class entries for a few extensions
Relates to GH-6644
2021-02-03 09:24:09 +01:00
Nikita Popov
3e01f5afb1 Replace zend_bool uses with bool
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool is retained as an alias.
2021-01-15 12:33:06 +01:00
Máté Kocsis
41b096b392
Promote a few forgotten warnings to exceptions
Closes GH-6211
2020-09-25 12:08:15 +02:00
George Peter Banyard
95f4ee38bb Add some ValueErrors to ext/date
Closes GH-5613
2020-09-16 01:29:28 +02:00
Máté Kocsis
8e8a277b2f
Slightly improve error handling in DatePeriod::__construct() 2020-09-14 11:59:51 +02:00
Derick Rethans
2ee2335249 Fixed bug #80057 (DateTimeImmutable::createFromFormat() does not populate time) 2020-09-04 15:55:08 +01:00
Nikita Popov
ecd986c879 Fix build warnings after timelib update 2020-08-31 14:28:39 +02:00
Nikita Popov
ac98ac7225 Merge branch 'PHP-7.4'
* PHP-7.4:
  Don't assert when comparing uninit DateTimeZone objects
2020-08-27 16:20:24 +02:00
Nikita Popov
5ae657b296 Don't assert when comparing uninit DateTimeZone objects
Nothing guarantees that the objects are initialized here... just
check as usual.
2020-08-27 16:18:45 +02:00
Nikita Popov
988fc94bbb Fix leak on failed DatePeriod initialization
We need to free not only p here, but also b and e.
2020-08-27 12:54:43 +02:00
Nikita Popov
e40c9d4918 Add some missing DatePeriod initialization checks 2020-08-13 17:23:23 +02:00
Nikita Popov
2965c8f868 Prefer strtoll over atoll
Both are specified by C99, but strtoll has specified overflow
behavior while atoll does not, so prefer using it.
2020-08-05 18:40:23 +02:00
Gregor Harlan
a6e3ce4fd6 datetime: new format "p", same as "P" but returning "Z" for UTC 2020-08-03 10:44:48 +02:00