📜 ⬆️ ⬇️

Translation of hours in Russia, again ... and php5-intl


Good% time of day%.

Prehistory


No signs of trouble. Long before tzdata were updated and everything that the hands could reach. But at the next moment of the transfer of hours, my site began to issue Moscow time for an hour more. A quick check showed that the OS itself, mysql and php (date function) return the time correctly and indicate the time zone +3 for Moscow. The dog was buried in a good extension php5-intl. The format function of the IntlDateFormatter class persistently returned the time zone +4 for Moscow.

Study


At the beginning, Google did not want to help me ... but soon I learned about such a beast as icu and another base of time zones, which, oddly enough, were not updated in my system. And everything would be fine ... apt-get update ... apt-get upgrade ... and ... the lack of an update for libicu FIG knows how long. Even good people started a bug in Debian about this. But things are there. Google stubbornly advised nothing good. Everything rested on the manual assembly of a fresh version. This option was even modestly illuminated in Habré . I, as a person far from the world of Linux, almost ruined the system in an attempt to build something. As a result, with the help of a good friend lsh and jointly enhanced googling, we found an easy way to update the data for libicu without compiling or other shamanism.

Decision


It turned out that libicu, being even compiled with direct inclusion of data, timezone, etc. inside .so, leaves the opportunity to slip their latest version through the instructions of the folder from where she could take them. This is done through the ICU_DATA environment variable. Having found all the pieces of the puzzle and after going through a couple of unsuccessful attempts, a simple and ready-to-use solution appeared:
')
And, no, I was not mistaken by placing the files in icu / icudt48l / and in the paths I specified only the icu folder. The thing is that libicu itself substitutes the folder for ICU_DATA based on its version (why ?!). So, in the future, when updating libicu, the folder will have to be renamed to another name. Judging by the observation, the name of the folder is formed as:
 icudt - icu data 48 -  libicu (4.8 -> 48, 3.6 -> 36) l -   (l - little-endian, b - big-endian) 
Accordingly, you need to name the folder based on the version of libicu on your system.

Restarting php-fpm and ... profit) now you can safely remove the crutch with the substitution instead of Europe / Moscow timezone Europe / Minsk :)

By the way, the question is why php-fpm ignores the global env? If anyone finds a way to specify this setting globally for all php-fpm workers, thank you very much.
@symbix notes that if you turn off the clear_env setting in php-fpm, then all php-fpm workers will start to see the global env, i.e. It is not necessary for each worker to specify env [ICU_DATA] separately. But the problem is that just the workers begin to see too much, and not just the line we need.


Strangely enough, but this simple method was difficult to google. I, like many before me, faced with this problem, tried to reassemble, pull out of the fresh test builds of distributions and much more. And what is even more strange is that this method is only briefly mentioned on the site themselves icu . I hope I closed this question for you.

Thank you and bezdezhnogo coding!

Source: https://habr.com/ru/post/254789/


All Articles