php8: update to 8.3.0
[feed/packages.git] / lang / php8 / patches / 0022-Use-system-timezone.patch
1 From: Debian PHP Maintainers <pkg-php-maint@lists.alioth.debian.org>
2 Date: Sat, 2 May 2015 10:26:56 +0200
3 Subject: Use system timezone
4
5 Upstream don't want this patch. See
6 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=730771 for a summary.
7
8 This delta is recovered from previous versions of the system timezone patch in
9 Debian, and appears to have inadvertently been dropped. Author unknown.
10
11 To be used in tandem with use_embedded_timezonedb.patch and use_embedded_timezonedb_fixes.patch.
12 ---
13 ext/date/php_date.c | 17 +++++++++++++++++
14 1 file changed, 17 insertions(+)
15
16 --- a/ext/date/php_date.c
17 +++ b/ext/date/php_date.c
18 @@ -567,6 +567,23 @@ static const char* guess_timezone(const
19 } else if (*DATEG(default_timezone)) {
20 return DATEG(default_timezone);
21 }
22 + /* Try to guess timezone from system information */
23 + {
24 + struct tm *ta, tmbuf;
25 + time_t the_time;
26 + char *tzid = NULL;
27 +
28 + the_time = time(NULL);
29 + ta = php_localtime_r(&the_time, &tmbuf);
30 + if (ta) {
31 + tzid = timelib_timezone_id_from_abbr(ta->tm_zone, ta->tm_gmtoff, ta->tm_isdst);
32 + }
33 + if (! tzid) {
34 + tzid = "UTC";
35 + }
36 +
37 + return tzid;
38 + }
39 /* Fallback to UTC */
40 return "UTC";
41 }