📜 ⬆️ ⬇️

Translation of hours in Russia on October 26 and icu4c

Many have already installed the tzdata update on their favorite distros and are looking forward to the end of the world on October 26, 2014, when you can feel yourself at all 3 at 2 am

But is everything OK if you write in PHP and use symfony Forms, or just php-intl ?!
My answer is no.

You can check yourself simply:

<?php $dateIn = '27.10.2014'; $tz = 'Europe/Moscow'; date_default_timezone_set($tz); $intlDateFormatter = new \IntlDateFormatter('ru_RU', 2, -1, $tz, 1, 'dd.MM.yyyy'); $timestamp = $intlDateFormatter->parse($dateIn); var_dump($intlDateFormatter->format($timestamp)); var_dump(date('dmY', $timestamp)); 

On Debian Wheezy, CentOS 6 after updating tzdata, this code will output:
 string(16) "27.10.2014" string(16) "26.10.2014" 

This is because the icu library has its own time zone database (this is a popular activity, for example, it also does php, java, chrome and a wagon of other software) and when recalculating the date in the unix timestamp it takes 4 hours, and the date php adds only 3, and if you only have a field for entering a date, then after dropping the time you will receive a day less from the entered date.
')
The situation is further aggravated by the fact that this data is stored as a library of libicudata, so be prepared to collect icu from source.

All actions are then performed on a separate VM running CentOS 6.5 + remi + libicu-last.

According to the version of the package, we determine the version of icu - 50.1.2 ( source code on the icu website ), also from here we download all * .res files, where (in the link)
2014i - tzdata version;
44 - libicu version (44 and all that is more);
le - little endian (dada if you have mips arm, etc. you may need a different set of resources).

 tar -zxf icu4c-50_1_2-src.tgz cd icu/source mkdir bin ./configure #   icupkg cd tools/icupkg/ make cd ../../ #     cd data/in/ #              ../../bin/icupkg -a zoneinfo64.res icudt50l.dat ../../bin/icupkg -a metaZones.res icudt50l.dat ../../bin/icupkg -a timezoneTypes.res icudt50l.dat ../../bin/icupkg -a windowsZones.res icudt50l.dat #     cd ../../ make 

In principle, this can be stopped and after the assembly, in the system, replace the library from / usr / lib64 / with the new version ./lib/libicudata.so.50.1.2.

I collected the package:

 yum install rpmrebuild rpmrebuild -e -p --notest-install libicu-last-50.1.2-10.el6.remi.x86_64.rpm 

According to the line of the form
 BuildRoot: /root/.tmp/rpmrebuild.42406/work/root 
determine where the unpacked package files are located and replace libicudata with the latest version, the resulting package (rpmbuild will write the full path after the build) can be installed with the --force key, since we did not change its version.

Thanks for attention!

UPD: Ubuntu users (Trusty | Precise) can take ready-made packages in ppa habrau users ranzhe

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


All Articles