Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113574 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 90539 invoked from network); 16 Mar 2021 19:10:49 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 16 Mar 2021 19:10:49 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 662AF1804D8 for ; Tue, 16 Mar 2021 12:04:38 -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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 16 Mar 2021 12:04:38 -0700 (PDT) Received: by mail-ed1-f43.google.com with SMTP id e7so22837021edu.10 for ; Tue, 16 Mar 2021 12:04:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=qLPebtobJEwxBlBsNsXx2aYiFwr/a2jEIQcG9wgoSKw=; b=JyEDuhvuAldoRYZGnUSyxW6ebT61+e/nPhqlu5LnSfIXX6Mul+ynBpmPSpBerh1mMh a/l1fQ4gPrARFzmwu9xZMTUBEEcbnTJKUEShH+Ma77akVTRepxhmXtmynWbKu0+k5qER 1iwryPoe4NCb3rFMRVWACX5GQr1jOyxF7cKPW0NaXsUOWe0i1zSZ3GTcHC4sy/xSOrTH QXB0tf6xulXMdv2Dzhx/mCnwgemT+xRTiiFfGNTFaD85dJQG50AjpEyhCN6rmWEW72gn MNUGgU8ORjpuF4bANfTLFuPW9Qp/YKUAWBNBFfL5VxUKMmUJ/W/WC4yJCQmbWtQ8tRHC b1Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=qLPebtobJEwxBlBsNsXx2aYiFwr/a2jEIQcG9wgoSKw=; b=gKwZ9nhtNN3z6Vqu9nfSH1KlzgvL/aHr23c4KioAE97Tt6UhD7Yy/haI/H7ZZoNE4A tc2dBkU4sGdz4JitKaXstx6pPt0F0hRlXSPWp0xncMqAKZOcbC3VAxYl3Bf1LvKGYfnD Kgo6D+8y3NBzP1LFRtRFOXdPpXx/4Z6mZyR5IXw9fxgRq2e7Kfv1VHLQ7r4kh7Ja3AFq dqHKUID+Tgij3sFngnJlykfUoES+5LN+sLhlJJuosVPzu1HeQve5cc77Sb7xTnaa7pY/ 5qf/fE5bG1fLxNDndzaiFQBzu64yo7DVvwd0JwDwyg1yYnAfVuw5eHSX9SUr+y8wyJnN LFHg== X-Gm-Message-State: AOAM530OGL2o1ELR6heps8+umLZP7p9QfuKgHf7bsLmjoLDcDyJslht6 VXcCugyywQvN1woMwgMcDbon74pGdgg= X-Google-Smtp-Source: ABdhPJydXKKtWJPWZVXdOQlnZue/G5dMIxH1sAOanhdtdxwnfzuT7nwxqKqrEcTf7A5Yl4+WYfi/RQ== X-Received: by 2002:a05:6402:5244:: with SMTP id t4mr38253494edd.87.1615921475231; Tue, 16 Mar 2021 12:04:35 -0700 (PDT) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id de17sm9867152ejc.16.2021.03.16.12.04.34 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Mar 2021 12:04:34 -0700 (PDT) To: internals@lists.php.net References: <05166649-DFD5-4B93-8D4C-1E19CE129EFF@9dev.de> Message-ID: <5a226984-dc4e-535a-ba01-62daacbe2107@gmail.com> Date: Tue, 16 Mar 2021 19:04:33 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <05166649-DFD5-4B93-8D4C-1E19CE129EFF@9dev.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [PHP-DEV] Add __toString() to DateInterval From: rowan.collins@gmail.com (Rowan Tommins) On 16/03/2021 18:56, Moritz Friedrich wrote: > Again, I’m not attached to `__toString()`. Having another helper method or a special formatting constant, as suggested by others in this thread, would likewise be a viable option. I’d merely prefer to have a built-in way of parsing*and* composing time intervals as per the ISO specification, making the API consistent and easing communication with non-PHP systems. Would a reasonable way forward be to have such a named method, and have it throw an exception if the instance is not representable in that form? That way, you'd be guaranteed that new DateInterval($period->toIsoPeriodString()) would result in an equivalent object, rather than discarding special relative values. Regards, -- Rowan Tommins [IMSoP]