Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96766 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20214 invoked from network); 8 Nov 2016 11:03:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Nov 2016 11:03:26 -0000 Authentication-Results: pb1.pair.com header.from=danack@basereality.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=danack@basereality.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain basereality.com from 209.85.213.182 cause and error) X-PHP-List-Original-Sender: danack@basereality.com X-Host-Fingerprint: 209.85.213.182 mail-yb0-f182.google.com Received: from [209.85.213.182] ([209.85.213.182:36232] helo=mail-yb0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 50/44-05967-CF0B1285 for ; Tue, 08 Nov 2016 06:03:26 -0500 Received: by mail-yb0-f182.google.com with SMTP id v78so65354105ybe.3 for ; Tue, 08 Nov 2016 03:03:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=basereality-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=P9jfeVGbyCJj7EmN2E88CI5ngMvtnJLOO+dIppdK46g=; b=nIxcZgvhFrByR5QZNICg1eYq+0R17dTnP59bhgsMqQN2T/J0gKLOT4JyovJ6EvwYsF nRomiOyATrq7NrL55g/+68L5vCZ8D1ZhMk9eXg1uVkjF/Cb74IuSs9Em134eorBKEMra We4szQoPbJ3R7mGYXXKVDukcRGAIlrxYucy7Zfr2+QHKWCeExrsTzKuoGJ8VV4s8ODcN hknCMvA0TEBHMYPJePArf/8LPgTYvv2cQohpo3Mo70w4iQyHW1dAlCPbteeY6d3NQxIO /ZPvUEZ0My0YPYxd3B/hfHUjQdn/Si9avt2XtQiYco+Rydu0PV5yHh6e6gYtKCdoUbtf Oz8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=P9jfeVGbyCJj7EmN2E88CI5ngMvtnJLOO+dIppdK46g=; b=WNRCQNyYlXhiidf4H5ck9xodjPECt1mhjvVP0RbUVOpI+S7IG9VLQ7hXxLpyvuvYt/ xPGk3fm6Ojz1R6sgBAgGItusNtthtMZ9UCkTIQrFHKbli+yTy9T/QrjcH3YtayWy5+vA 1TS3qy4woBARV0oCxOZsWVpyuS4HHOZOkY4EqIMAehiJG85/6cUgJSlkiHh3fyENuNbu SVq9i8qE180fnoMf41xqT8M6aQIi1xCBAozwLOkuUX+LEYJ2Xw0m+8XwowgEz3PSTTrC 0xqrtXvQNMI52LLvF3SjSEEEEIlFd17tqH5ZOEOEEkf8W221+MnsQuOM6xqbJQj5auwP SzyA== X-Gm-Message-State: ABUngvf/R9f0xVDiAXD7U4sufGosu62mK+FB8uq31Xk86RVevQHFLZA451pwCoT97ehL1CCt8iHUzSD7oQGweA== X-Received: by 10.37.63.3 with SMTP id m3mr176848yba.85.1478603001662; Tue, 08 Nov 2016 03:03:21 -0800 (PST) MIME-Version: 1.0 Received: by 10.37.68.131 with HTTP; Tue, 8 Nov 2016 03:03:21 -0800 (PST) X-Originating-IP: [78.33.10.171] In-Reply-To: <46.92.05967.9AB91285@pb1.pair.com> References: <46.92.05967.9AB91285@pb1.pair.com> Date: Tue, 8 Nov 2016 11:03:21 +0000 Message-ID: To: Arjen Schol Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] DateTime microseconds discussion From: danack@basereality.com (Dan Ackroyd) On 8 November 2016 at 09:32, Arjen Schol wrote: > Hi, > > Support for microseconds was added late in the 7.1 RC cycle, however is h= as > some issues: My understanding is that if this affects your code, then your code already has a bad assumption in it. The code is mistakenly assuming that two DateTime's generated will have the same the same time for both of them.* I don't fully understand what problem you are want to solve through this discussion. No-one is forcing you to update to PHP 7.1 immediately; you should have plenty of time to fix the code that has bad assumptions about the time in a generated DateTime before you upgrade to PHP 7.1. SjonHortensius wrote: > if generating a DateTime takes roughly 4 =CE=BCs (which it does for me), = this happens ~ 250.000 times > more often Having bugs happen more frequently is a good thing. It stops you from ignoring edge cases and programming by coincidence.** I realise that having a release make it more obvious that broken code is broken is an annoying thing to have to fix....but that code is already wrong. Delaying useful features, just to avoid having to fix flaky code is not a good way for a project to proceed, imo. dshafik wrote: > I think default microseconds to 0 when unspecific for relative strings is= correct behavior I don't think that sounds like a good plan at all. When creating a DateTime through `new DateTime('first day of next month');` only the date values are set from the input string, the rest of the time is set to now(). Wouldn't having microseconds behave differently to the rest of the time values would be instantly an extra piece of inconsistency for people to regret? cheers Dan * Example code that doesn't work correctly now. If the sleep period is reduced, it becomes less obvious that the code is broken, but it is still broken. for ($i=3D0; $i<10; $i++) { $dt1 =3D new DateTime('first day of next month'); usleep(rand(0, 500000)); $dt2 =3D new DateTime('first day of next month'); if ($dt1 =3D=3D $dt2) { echo "Same\n"; } else { echo "Different\n"; } } ** Programming by Coincidence - https://pragprog.com/the-pragmatic-programmer/extracts/coincidence