[RFC] Add IntlDateTimePatternGenerator
| From: | Mel Dafert | Date: | Sat, 24 Apr 2021 15:12:12 +0000 |
| Subject: | [RFC] Add IntlDateTimePatternGenerator | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-114124@lists.php.net to get a copy of this message | ||
Hi Internals,
I would like to propose an RFC https://wiki.php.net/rfc/intldatetimepatterngenerator
to add IntlDateTimePatternGenerator
which exposes ICU's ability to flexibly create localized date/time formatting patterns from a
skeleton.
Previous discussion: https://externals.io/message/113831
Implementation: https://github.com/php/php-src/pull/6771
Proposed signature:
```
class IntlDateTimePatternGenerator
{
public function __construct(?string $locale = null) {}
public static function create(?string $locale = null): ?IntlDateTimePatternGenerator {}
public function getBestPattern(string $skeleton): string|false {}
}
```
There is an open question about what this should be named
IntlDatePatternGenerator
instead, both for brevity and to keep consistency
with IntlDateFormatter. (Note that the underlying ICU classes are called
DateTimePatternGenerator and DateFormatter, respectively.)
I am open to switching to the shorter form.
Another open question is the signature, as currently both __construct and
create are exposed (like IntlDateFormatter).
Other classes inside the intl extension (like IntlCalendar) only provide a static
create method, and leave the __construct method
private. Is there a preferred way, or are both equivalent?
Regards,
Mel