Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122366 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 66592 invoked from network); 14 Feb 2024 00:49:19 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 Feb 2024 00:49:19 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1707871815; bh=L9vshQ57RJJ46f7gzgyM5T0HQSPK9ciVtZg9+PzIvnM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=JXp6oz+Yb9qjetLWA6U1daxnT+epp7BMBcGzP3oaX8AMiiDHwCVj1+vDj23FIq+u0 gU9oIzgzzVddnQywaxV0irXi/1Dz8UCOxUfi6IbUoPWkWZTeX8n0kObtkxTPdWalAe Z+hGdi0/+RyhKilAaa1aJCmsu/b+lotlH/8i31w8RotjL/k46DOPa7B9lRQuUxqsIb aBvlp5zVr2/pA5p0d38y3Luhn3tjGtFhHabct6MrvT55kUs/xlUaz7eU8mSRWl2arO zYssdOKzKXKjaCkdmXJsOnT+uXr5bxGazv543WImI0D8A19tLWzjl5tc32x4zJnm4M 7qhgLQFFRMmKg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A680618006C for ; Tue, 13 Feb 2024 16:50:13 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from forward500a.mail.yandex.net (forward500a.mail.yandex.net [178.154.239.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 13 Feb 2024 16:50:12 -0800 (PST) Received: from mail-nwsmtp-smtp-production-main-49.vla.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-49.vla.yp-c.yandex.net [IPv6:2a02:6b8:c18:4601:0:640:7543:0]) by forward500a.mail.yandex.net (Yandex) with ESMTPS id ABFC561191 for ; Wed, 14 Feb 2024 03:49:13 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-49.vla.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id Dnbeew11JKo0-zLBvtu0Y; Wed, 14 Feb 2024 03:49:13 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=php.watch; s=mail; t=1707871753; bh=L9vshQ57RJJ46f7gzgyM5T0HQSPK9ciVtZg9+PzIvnM=; h=To:Subject:Message-ID:References:Date:From:In-Reply-To:Cc; b=O3QQKPy0B7I8HIaDPAanBVWSiwZwq2dQmh7FNupM4ftg7Dn6JLDQpFC+BIFyDo2j2 29KiIvB9fZNaa9cCZbJvcn1l3gq/gyDVOV7ATLKDdCtkezWbZpPK+ofwQG0TDg2l6k CVUNRilytBlKtAx5L8yf+X+dMi9qX37vBFrSiC6g= Authentication-Results: mail-nwsmtp-smtp-production-main-49.vla.yp-c.yandex.net; dkim=pass header.i=@php.watch Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-51182f8590bso4158565e87.0 for ; Tue, 13 Feb 2024 16:49:13 -0800 (PST) X-Gm-Message-State: AOJu0YyMPk16ZRzJ6Ka4A++2+o92hAny3jdycj35OnxBd8mNiV3tJHwC CpA/XHBSIX0X85hoftE6Vx2ild0F8PpV9iz65wG0jH2FVPf6XXtdqzwfvrANYb7yT3Vo6oE24B3 BZQDMCywQ+KAVcJDIWZd5TUqO0pg= X-Google-Smtp-Source: AGHT+IEE2e7+a3Jf9vLW1xePKSPPKNNg2mzuIWHolJFEo2N/uyTCXIcPFOeB+G+EQkxsyvwjmxk4O/8Wiw9lbffga1U= X-Received: by 2002:a05:6512:3e0d:b0:511:62f5:9068 with SMTP id i13-20020a0565123e0d00b0051162f59068mr955412lfv.11.1707871752908; Tue, 13 Feb 2024 16:49:12 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 14 Feb 2024 07:48:46 +0700 X-Gmail-Original-Message-ID: Message-ID: To: Hans Henrik Bergan Cc: PHP Internals List Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] int|float for DateTime::setTimestamp From: ayesh@php.watch (Ayesh Karunaratne) > > just like the constructor accepts > new DateTime("@0.123456"); // 1970-01-01 00:00:00.123456 > new DateTime("@".microtime(true)); > > IMO setTimestamp should accept the same: > $dt->setTimestamp(0.123456); // 1970-01-01 00:00:00.123456 > $dt->setTimestamp(microtime(true)); > > Can we change setTimestamp to accept int|float? > made a PR https://github.com/php/php-src/pull/13383 You are probably already aware, but PHP 8.4 will have a new `DateTime::get/setMicroseconds` method[^1][^2] that accepts an integer microsecond value. That said, I personally think it makes sense to accept float values for fractions of seconds, but changing the parameter type WILL be be a BC break because all subclasses extending `setTimestamp` will not be compatible unless they are changed to `int|float` or wider. [^1]: https://github.com/php/php-src/commit/0016b3085cf06e8a189ecc53c31697e3a108dbdd [^2]: https://php.watch/versions/8.4/date-datetime-get-setMicroseconds