Use system timezone
authorDebian PHP Maintainers <pkg-php-maint@lists.alioth.debian.org>
Sat, 2 May 2015 08:26:56 +0000 (10:26 +0200)
committerOndřej Surý <ondrej@debian.org>
Fri, 27 Sep 2024 03:52:57 +0000 (05:52 +0200)
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.

Gbp-Pq: Name 0021-Use-system-timezone.patch

ext/date/php_date.c

index 87dd917749187c797106ea7bfbd03cc1c46915ca..3d0135a1081045a58fc77390be6a8d632741f0bb 100644 (file)
@@ -549,6 +549,23 @@ static 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";
 }