File: 0020-Use-system-timezone.patch

package info (click to toggle)
php8.4 8.4.11-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 208,108 kB
  • sloc: ansic: 1,060,628; php: 35,345; sh: 11,866; cpp: 7,201; pascal: 4,913; javascript: 3,091; asm: 2,810; yacc: 2,411; makefile: 689; xml: 446; python: 301; awk: 148
file content (43 lines) | stat: -rw-r--r-- 1,287 bytes parent folder | download
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
From: Debian PHP Maintainers <pkg-php-maint@lists.alioth.debian.org>
Date: Sat, 2 May 2015 10:26:56 +0200
Subject: Use system timezone

Upstream don't want this patch. See
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=730771 for a summary.

This delta is recovered from previous versions of the system timezone patch in
Debian, and appears to have inadvertently been dropped. Author unknown.

To be used in tandem with use_embedded_timezonedb.patch and use_embedded_timezonedb_fixes.patch.
---
 ext/date/php_date.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 94ffd97..172e2f0 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -566,6 +566,23 @@ static const char* guess_timezone(const timelib_tzdb *tzdb)
 	} else if (*DATEG(default_timezone)) {
 		return DATEG(default_timezone);
 	}
+	/* Try to guess timezone from system information */
+	{
+		struct tm *ta, tmbuf;
+		time_t     the_time;
+		char      *tzid = NULL;
+
+		the_time = time(NULL);
+		ta = php_localtime_r(&the_time, &tmbuf);
+		if (ta) {
+			tzid = timelib_timezone_id_from_abbr(ta->tm_zone, ta->tm_gmtoff, ta->tm_isdst);
+		}
+		if (! tzid) {
+			tzid = "UTC";
+		}
+
+		return tzid;
+	}
 	/* Fallback to UTC */
 	return "UTC";
 }