(PHP 5 >= 5.5.0, PHP 7, PHP 8, PECL >= 3.0.0a1)
IntlCalendar::getDayOfWeekType — Indique si un jour est un jour de la semaine, un week-end ou un jour de transition entre les deux
Style orienté objet
Style procédural
Renvoie si le jour passé est un jour de semaine
(IntlCalendar::DOW_TYPE_WEEKDAY), un jour de week-end
(IntlCalendar::DOW_TYPE_WEEKEND), un jour de transition
vers le week-end
(IntlCalendar::DOW_TYPE_WEEKEND_OFFSET) ou un jour de
transition hors du week-end
(IntlCalendar::DOW_TYPE_WEEKEND_CEASE).
Si le retour est soit
IntlCalendar::DOW_TYPE_WEEKEND_OFFSET ou
IntlCalendar::DOW_TYPE_WEEKEND_CEASE, alors
IntlCalendar::getWeekendTransition() peut être appelée pour
obtenir le temps de la transition.
Cette fonction nécessite ICU 4.4 ou plus récent.
calendarUne instance IntlCalendar.
dayOfWeek
Une des constantes IntlCalendar::DOW_SUNDAY,
IntlCalendar::DOW_MONDAY, …,
IntlCalendar::DOW_SATURDAY.
Une des constantes
IntlCalendar::DOW_TYPE_WEEKDAY,
IntlCalendar::DOW_TYPE_WEEKEND,
IntlCalendar::DOW_TYPE_WEEKEND_OFFSET ou
IntlCalendar::DOW_TYPE_WEEKEND_CEASE ou false si une erreur survient.
Exemple #1 IntlCalendar::getDayOfWeekType()
<?php
foreach (array('en_US', 'ar_SA') as $locale) {
echo "Locale: ", Locale::getDisplayName($locale, "en_US"), "\n";
$cal = IntlCalendar::createInstance('UTC', $locale);
for ($i = IntlCalendar::DOW_SUNDAY; $i <= IntlCalendar::DOW_SATURDAY; $i++) {
$type = $cal->getDayOfWeekType($i);
$transition = ($type !== IntlCalendar::DOW_TYPE_WEEKDAY)
? $cal->getWeekendTransition($i)
: '';
echo $i, " ", $type, " ", $transition, "\n";
}
echo "\n";
}
?>L'exemple ci-dessus va afficher :
Locale: English (United States) 1 1 86400000 2 0 3 0 4 0 5 0 6 0 7 1 0 Locale: Arabic (Saudi Arabia) 1 0 2 0 3 0 4 0 5 0 6 1 0 7 1 86400000