CakeFest 2024: The Official CakePHP Conference

IntlCalendar::equals

(PHP 5 >= 5.5.0, PHP 7, PHP 8, PECL >= 3.0.0a1)

IntlCalendar::equalsふたつの IntlCalendar オブジェクトの時刻を比較する

説明

オブジェクト指向型

public IntlCalendar::equals(IntlCalendar $other): bool

手続き型

intlcal_equals(IntlCalendar $calendar, IntlCalendar $other): bool

このカレンダーオブジェクトと、 指定されたカレンダーオブジェクトの時刻が同じなら、true を返します。 カレンダーの型とフィールドの状態は、必ずしも同じである必要はありません。

パラメータ

calendar

IntlCalendar クラスのインスタンス。

other

比較対象のカレンダーオブジェクト。

戻り値

このカレンダーオブジェクトと、 渡された IntlCalendar の時刻が同じな場合、 true を返します。 そうでない場合、false を返します。

失敗時に false を返します。エラーを検知するには、intl_get_error_code() を使うか、 Intl拡張モジュールが 例外 をスローするように設定して下さい。

例1 IntlCalendar::equals()

<?php
ini_set
('date.timezone', 'UTC');

$cal1 = IntlCalendar::createInstance(NULL, 'es_ES');
$cal2 = clone $cal1;

var_dump($cal1->equals($cal2)); //TRUE

//The locale is not included in the comparison
$cal2 = IntlCalendar::createInstance(NULL, 'pt_PT');
$cal2->setTime($cal1->getTime());
var_dump($cal1->equals($cal2)); //TRUE

//And set fields state is not included as well
$cal2->clear(IntlCalendar::FIELD_YEAR);
var_dump($cal1->isSet(IntlCalendar::FIELD_YEAR) ==
$cal2->isSet(IntlCalendar::FIELD_YEAR)); //FALSE
var_dump($cal1->equals($cal2)); //TRUE

//Neither is the calendar type
$cal2 = IntlCalendar::createInstance(NULL, 'es_ES@calendar=islamic');
$cal2->setTime($cal1->getTime());
var_dump($cal1->equals($cal2)); //TRUE

//Only the time is
$cal2 = clone $cal1;
$cal2->setTime($cal1->getTime() + 1.);
var_dump($cal1->equals($cal2)); //FALSE

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top