|
| 1 | +--TEST-- |
| 2 | +IntlDateFormatter: setCalendar()/getCalendar()/getCalendarObject() for ICU >= 70.1 |
| 3 | +--EXTENSIONS-- |
| 4 | +intl |
| 5 | +--SKIPIF-- |
| 6 | +<?php |
| 7 | +if (version_compare(INTL_ICU_VERSION, '70.1') < 0) die('skip for ICU >= 70.1'); |
| 8 | +?> |
| 9 | +--FILE-- |
| 10 | +<?php |
| 11 | +ini_set("intl.error_level", E_WARNING); |
| 12 | +ini_set("intl.default_locale", "pt_PT"); |
| 13 | +ini_set("date.timezone", 'Atlantic/Azores'); |
| 14 | + |
| 15 | +$ts = strtotime('2012-01-01 00:00:00 UTC'); |
| 16 | + |
| 17 | +function d(IntlDateFormatter $df) { |
| 18 | +global $ts; |
| 19 | +echo $df->format($ts), "\n"; |
| 20 | +var_dump($df->getCalendar(), |
| 21 | +$df->getCalendarObject()->getType(), |
| 22 | +$df->getCalendarObject()->getTimeZone()->getId()); |
| 23 | +echo "\n"; |
| 24 | +} |
| 25 | + |
| 26 | +$df = new IntlDateFormatter('fr@calendar=islamic', 0, 0, 'Europe/Minsk'); |
| 27 | +d($df); |
| 28 | + |
| 29 | + |
| 30 | +//changing the calendar with a cal type should not change tz |
| 31 | +$df->setCalendar(IntlDateFormatter::TRADITIONAL); |
| 32 | +d($df); |
| 33 | + |
| 34 | +//but changing with an actual calendar should |
| 35 | +$cal = IntlCalendar::createInstance("UTC"); |
| 36 | +$df->setCalendar($cal); |
| 37 | +d($df); |
| 38 | + |
| 39 | +?> |
| 40 | +--EXPECT-- |
| 41 | +dimanche 1 janvier 2012 ap. J.-C. à 03:00:00 heure de Kaliningrad |
| 42 | +int(1) |
| 43 | +string(9) "gregorian" |
| 44 | +string(12) "Europe/Minsk" |
| 45 | + |
| 46 | +dimanche 8 safar 1433 AH à 03:00:00 heure de Kaliningrad |
| 47 | +int(0) |
| 48 | +string(7) "islamic" |
| 49 | +string(12) "Europe/Minsk" |
| 50 | + |
| 51 | +dimanche 1 janvier 2012 ap. J.-C. à 00:00:00 temps universel coordonné |
| 52 | +bool(false) |
| 53 | +string(9) "gregorian" |
| 54 | +string(3) "UTC" |
| 55 | + |
0 commit comments