Skip to content

Instantly share code, notes, and snippets.

@Maksold
Created May 3, 2022 05:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Maksold/b83ff5ae970433d5e5cc2e0b0c766935 to your computer and use it in GitHub Desktop.
Save Maksold/b83ff5ae970433d5e5cc2e0b0c766935 to your computer and use it in GitHub Desktop.
diff --git a/ext/intl/breakiterator/codepointiterator_internal.cpp b/ext/intl/breakiterator/codepointiterator_internal.cpp
index 723cfd5022..f6f75d2731 100644
--- a/ext/intl/breakiterator/codepointiterator_internal.cpp
+++ b/ext/intl/breakiterator/codepointiterator_internal.cpp
@@ -74,7 +74,11 @@ CodePointBreakIterator::~CodePointBreakIterator()
clearCurrentCharIter();
}
+#if U_ICU_VERSION_MAJOR_NUM >= 70
+bool CodePointBreakIterator::operator==(const BreakIterator& that) const
+#else
UBool CodePointBreakIterator::operator==(const BreakIterator& that) const
+#endif
{
if (typeid(*this) != typeid(that)) {
return FALSE;
diff --git a/ext/intl/breakiterator/codepointiterator_internal.h b/ext/intl/breakiterator/codepointiterator_internal.h
index d34fc0a2c2..25759c167a 100644
--- a/ext/intl/breakiterator/codepointiterator_internal.h
+++ b/ext/intl/breakiterator/codepointiterator_internal.h
@@ -36,7 +36,11 @@ namespace PHP {
virtual ~CodePointBreakIterator();
+#if U_ICU_VERSION_MAJOR_NUM >= 70
+ virtual bool operator==(const BreakIterator& that) const;
+#else
virtual UBool operator==(const BreakIterator& that) const;
+#endif
virtual CodePointBreakIterator* clone(void) const;
diff --git a/ext/intl/locale/locale_methods.c b/ext/intl/locale/locale_methods.c
index 3379916822..4fb0bfcaa5 100644
--- a/ext/intl/locale/locale_methods.c
+++ b/ext/intl/locale/locale_methods.c
@@ -1333,7 +1333,7 @@ PHP_FUNCTION(locale_filter_matches)
if( token && (token==cur_lang_tag) ){
/* check if the char. after match is SEPARATOR */
chrcheck = token + (strlen(cur_loc_range));
- if( isIDSeparator(*chrcheck) || isEndOfTag(*chrcheck) ){
+ if( isIDSeparator(*chrcheck) || isKeywordSeparator(*chrcheck) || isEndOfTag(*chrcheck) ){
if( cur_lang_tag){
efree( cur_lang_tag );
}
@@ -1389,7 +1389,7 @@ PHP_FUNCTION(locale_filter_matches)
if( token && (token==cur_lang_tag) ){
/* check if the char. after match is SEPARATOR */
chrcheck = token + (strlen(cur_loc_range));
- if( isIDSeparator(*chrcheck) || isEndOfTag(*chrcheck) ){
+ if( isIDSeparator(*chrcheck) || isKeywordSeparator(*chrcheck) || isEndOfTag(*chrcheck) ){
if( cur_lang_tag){
efree( cur_lang_tag );
}
diff --git a/ext/intl/tests/dateformat_get_set_calendar_variant5.phpt b/ext/intl/tests/dateformat_get_set_calendar_variant5.phpt
index 43e9a8516b..6f828b0305 100644
--- a/ext/intl/tests/dateformat_get_set_calendar_variant5.phpt
+++ b/ext/intl/tests/dateformat_get_set_calendar_variant5.phpt
@@ -1,9 +1,9 @@
--TEST--
-IntlDateFormatter: setCalendar()/getCalendar()/getCalendarObject()
+IntlDateFormatter: setCalendar()/getCalendar()/getCalendarObject() for ICU >= 58.1 and < 70.1
--SKIPIF--
<?php
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
-<?php if (version_compare(INTL_ICU_VERSION, '58.1') < 0) die('skip for ICU >= 58.1'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '58.1') < 0 || version_compare(INTL_ICU_VERSION, '70.1') >= 0) die('skip for ICU >= 58.1 and < 70.1'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
diff --git a/ext/intl/tests/dateformat_get_set_calendar_variant5_icu70.phpt b/ext/intl/tests/dateformat_get_set_calendar_variant5_icu70.phpt
new file mode 100644
index 0000000000..fcea014497
--- /dev/null
+++ b/ext/intl/tests/dateformat_get_set_calendar_variant5_icu70.phpt
@@ -0,0 +1,53 @@
+--TEST--
+IntlDateFormatter: setCalendar()/getCalendar()/getCalendarObject() for ICU >= 70.1
+--EXTENSIONS--
+intl
+--SKIPIF--
+<?php if (version_compare(INTL_ICU_VERSION, '70.1') < 0) die('skip for ICU >= 70.1'); ?>
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "pt_PT");
+ini_set("date.timezone", 'Atlantic/Azores');
+
+$ts = strtotime('2012-01-01 00:00:00 UTC');
+
+function d(IntlDateFormatter $df) {
+global $ts;
+echo $df->format($ts), "\n";
+var_dump($df->getCalendar(),
+$df->getCalendarObject()->getType(),
+$df->getCalendarObject()->getTimeZone()->getId());
+echo "\n";
+}
+
+$df = new IntlDateFormatter('fr@calendar=islamic', 0, 0, 'Europe/Minsk');
+d($df);
+
+
+//changing the calendar with a cal type should not change tz
+$df->setCalendar(IntlDateFormatter::TRADITIONAL);
+d($df);
+
+//but changing with an actual calendar should
+$cal = IntlCalendar::createInstance("UTC");
+$df->setCalendar($cal);
+d($df);
+
+?>
+--EXPECT--
+dimanche 1 janvier 2012 ap. J.-C. à 03:00:00 heure de Kaliningrad
+int(1)
+string(9) "gregorian"
+string(12) "Europe/Minsk"
+
+dimanche 8 safar 1433 AH à 03:00:00 heure de Kaliningrad
+int(0)
+string(7) "islamic"
+string(12) "Europe/Minsk"
+
+dimanche 1 janvier 2012 ap. J.-C. à 00:00:00 temps universel coordonné
+bool(false)
+string(9) "gregorian"
+string(3) "UTC"
+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment