Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114124 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 99472 invoked from network); 24 Apr 2021 15:08:46 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 24 Apr 2021 15:08:46 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 51CB31804DC for ; Sat, 24 Apr 2021 08:12:18 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail02.x-net.at (mail02.x-net.at [83.65.141.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 24 Apr 2021 08:12:17 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by mail02.x-net.at (Postfix) with ESMTP id 541B63800DB for ; Sat, 24 Apr 2021 17:12:16 +0200 (CEST) Received: from mail02.x-net.at ([127.0.0.1]) by localhost (x-zimbra02.x [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 2W5lAwA452kw for ; Sat, 24 Apr 2021 17:12:13 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail02.x-net.at (Postfix) with ESMTP id 2028F380B36 for ; Sat, 24 Apr 2021 17:12:13 +0200 (CEST) X-Virus-Scanned: amavisd-new at x-t.at Received: from mail02.x-net.at ([127.0.0.1]) by localhost (x-zimbra02.x [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 9TS7MleUcyML for ; Sat, 24 Apr 2021 17:12:13 +0200 (CEST) Received: from x-zimbra02.x (localhost [127.0.0.1]) by mail02.x-net.at (Postfix) with ESMTP id 083743800DB for ; Sat, 24 Apr 2021 17:12:13 +0200 (CEST) Date: Sat, 24 Apr 2021 17:12:12 +0200 (CEST) To: internals Message-ID: <254589645.2058488.1619277132719.JavaMail.zimbra@dafert.at> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Mailer: Zimbra 8.8.15_GA_3959 (ZimbraWebClient - FF87 (Linux)/8.8.15_GA_3953) Thread-Index: p6Jj4g9gVSee+btm6l+odYb9naHAxw== Thread-Topic: Add IntlDateTimePatternGenerator Subject: [RFC] Add IntlDateTimePatternGenerator From: mel@dafert.at (Mel Dafert) 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