You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.2 KiB

  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. Upstream don't want this patch. See
  5. http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=730771 for a summary.
  6. This delta is recovered from previous versions of the system timezone patch in
  7. Debian, and appears to have inadvertently been dropped. Author unknown.
  8. To be used in tandem with use_embedded_timezonedb.patch and use_embedded_timezonedb_fixes.patch.
  9. ---
  10. ext/date/php_date.c | 17 +++++++++++++++++
  11. 1 file changed, 17 insertions(+)
  12. diff --git a/ext/date/php_date.c b/ext/date/php_date.c
  13. index e780b2e..2b5a528 100644
  14. --- a/ext/date/php_date.c
  15. +++ b/ext/date/php_date.c
  16. @@ -992,6 +992,23 @@ static char* guess_timezone(const timelib_tzdb *tzdb)
  17. DATEG(timezone_valid) = 1;
  18. return DATEG(default_timezone);
  19. }
  20. + /* Try to guess timezone from system information */
  21. + {
  22. + struct tm *ta, tmbuf;
  23. + time_t the_time;
  24. + char *tzid = NULL;
  25. +
  26. + the_time = time(NULL);
  27. + ta = php_localtime_r(&the_time, &tmbuf);
  28. + if (ta) {
  29. + tzid = timelib_timezone_id_from_abbr(ta->tm_zone, ta->tm_gmtoff, ta->tm_isdst);
  30. + }
  31. + if (! tzid) {
  32. + tzid = "UTC";
  33. + }
  34. +
  35. + return tzid;
  36. + }
  37. /* Fallback to UTC */
  38. return "UTC";
  39. }