|
| 1 | +--TEST-- |
| 2 | +IntlDateFormatter: several forms of the calendar arg |
| 3 | +--SKIPIF-- |
| 4 | +<?php |
| 5 | +if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?> |
| 6 | +<?php if (version_compare(INTL_ICU_VERSION, '58.1') < 0) die('skip for ICU >= 58.1'); ?> |
| 7 | +--FILE-- |
| 8 | +<?php |
| 9 | +ini_set("intl.error_level", E_WARNING); |
| 10 | +ini_set("intl.default_locale", "pt_PT"); |
| 11 | +ini_set("date.timezone", 'Atlantic/Azores'); |
| 12 | + |
| 13 | +$ts = strtotime('2012-01-01 00:00:00 UTC'); |
| 14 | + |
| 15 | +$cal = new IntlGregorianCalendar('UTC', NULL); |
| 16 | +$df = new IntlDateFormatter('es_ES', 0, 0, NULL, $cal); |
| 17 | +echo $df->format($ts), "\n"; |
| 18 | + |
| 19 | +$cal = IntlCalendar::createInstance('UTC', 'en@calendar=islamic'); |
| 20 | +$df = new IntlDateFormatter('es_ES', 0, 0, NULL, $cal); |
| 21 | +echo $df->format($ts), "\n"; |
| 22 | + |
| 23 | +//override calendar's timezone |
| 24 | +$cal = new IntlGregorianCalendar('UTC', NULL); |
| 25 | +$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Madrid', $cal); |
| 26 | +echo $df->format($ts), "\n"; |
| 27 | + |
| 28 | +//default calendar is gregorian |
| 29 | +$df = new IntlDateFormatter('es_ES@calendar=islamic', 0, 0); |
| 30 | +echo $df->format($ts), "\n"; |
| 31 | + |
| 32 | +//try now with traditional |
| 33 | +$df = new IntlDateFormatter('es_ES@calendar=islamic', 0, 0, NULL, IntlDateFormatter::TRADITIONAL); |
| 34 | +echo $df->format($ts), "\n"; |
| 35 | + |
| 36 | +//the timezone can be overridden when not specifying a calendar |
| 37 | +$df = new IntlDateFormatter('es_ES@calendar=islamic', 0, 0, 'UTC', IntlDateFormatter::TRADITIONAL); |
| 38 | +echo $df->format($ts), "\n"; |
| 39 | + |
| 40 | +$df = new IntlDateFormatter('es_ES', 0, 0, 'UTC', 0); |
| 41 | +echo $df->format($ts), "\n"; |
| 42 | + |
| 43 | +?> |
| 44 | +==DONE== |
| 45 | +--EXPECTF-- |
| 46 | +domingo%S 1 de enero de 2012, 0:00:00 (%siempo %sniversal %sordinado) |
| 47 | +domingo%S 8 de %safar de 1433, 0:00:00 (%siempo %sniversal %sordinado) |
| 48 | +domingo, 1 de enero de 2012, 1:00:00 (hora estándar de Europa central) |
| 49 | +sábado, 31 de diciembre de 2011 d. C., 23:00:00 (hora estándar de las Azores) |
| 50 | +sábado, 7 de %safar de 1433 AH, 23:00:00 (hora estándar de las Azores) |
| 51 | +domingo%S 8 de %safar de 1433 AH, 0:00:00 (%siempo %sniversal %sordinado) |
| 52 | +domingo%S 1 de enero de 2012, 0:00:00 (%siempo %sniversal %sordinado) |
| 53 | +==DONE== |
0 commit comments