Skip to content

Commit bfa8444

Browse files
committed
minor #11472 Documented the Timezones Intl bundle (javiereguiluz)
This PR was squashed before being merged into the master branch (closes #11472). Discussion ---------- Documented the Timezones Intl bundle Fixes #11447. Commits ------- 9a201fb Documented the Timezones Intl bundle
2 parents 77392ed + 9a201fb commit bfa8444

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

components/intl.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ This component provides the following ICU data:
215215
* `Country and Region Names`_
216216
* `Locales`_
217217
* `Currencies`_
218+
* `Timezones`_
218219

219220
Language and Script Names
220221
~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -376,6 +377,39 @@ You can also check if a given currency code is valid::
376377

377378
The ``Currencies`` class was introduced in Symfony 4.3.
378379

380+
Timezones
381+
~~~~~~~~~
382+
383+
The ``Timezones`` class provides access to the name and values of all timezones::
384+
385+
use Symfony\Component\Intl\Timezones;
386+
387+
\Locale::setDefault('en');
388+
389+
$timezones = Timezones::getNames();
390+
// ('timezoneName' => 'timezoneValue')
391+
// => ['America/Eirunepe' => 'Acre Time (Eirunepe)', 'America/Rio_Branco' => 'Acre Time (Rio Branco)', ...]
392+
393+
$timezone = Timezones::getName('Africa/Nairobi');
394+
// => 'East Africa Time (Nairobi)'
395+
396+
All methods accept the translation locale as the last, optional parameter,
397+
which defaults to the current default locale::
398+
399+
$timezones = Timezones::getNames('de');
400+
// => ['America/Eirunepe' => 'Acre-Zeit (Eirunepe)', 'America/Rio_Branco' => 'Acre-Zeit (Rio Branco)', ...]
401+
402+
$timezone = Timezones::getName('Africa/Nairobi', 'de');
403+
// => 'Ostafrikanische Zeit (Nairobi)'
404+
405+
You can also check if a given timezone name is valid::
406+
407+
$isValidTimezone = Timezones::exists($timezoneName);
408+
409+
.. versionadded:: 4.3
410+
411+
The ``Timezones`` class was introduced in Symfony 4.3.
412+
379413
Learn more
380414
----------
381415

0 commit comments

Comments
 (0)