Time change in Russia on October 26 and icu4c

Many have already installed the tzdata update on their favorite distributions and are looking forward to the end of the world on October 26, 2014, when you can feel at all at 2 a.m.

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

You can check yourself simply:

parse($dateIn);
var_dump($intlDateFormatter->format($timestamp));
var_dump(date('d.m.Y', $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 carriage of other software) and when recalculating the date in unix timestamp, it takes 4 hours, and the php date function only adds 3, and if the field is for entering the date only, then after dropping the time, you will receive a day less from the entered date.

The situation is aggravated by the fact that this data is stored in the form of a libicudata library, so get ready to collect icu from source.

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

According to the package version, we determine the icu version - 50.1.2 ( sources on the icu website ), also from heredownload all * .res files, where (in the link)
2014i is the tzdata version;
44 - version of libicu (44 and all that is more);
le - little endian (yes 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, we can stop here and after the assembly, replace the library from / usr / lib64 / with the new version ./lib/libicudata.so.50.1.2 in the system.

I put together the package:

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

By line view
BuildRoot: /root/.tmp/rpmrebuild.42406/work/root
we 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 switch, since we did not change its version.

Thanks for attention!

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

Also popular now: