blob: 10c057e40799c1bc7c48de74a9a9dcd16df193bb (
plain)
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
|
index cf4a11b..f2ea919 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -545,6 +545,23 @@ static char* guess_timezone(const timelib_tzdb *tzdb)
DATEG(timezone_valid) = 1;
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";
}
|