Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96771 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43712 invoked from network); 8 Nov 2016 13:04:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Nov 2016 13:04:07 -0000 Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 82.113.146.227 as permitted sender) X-PHP-List-Original-Sender: derick@php.net X-Host-Fingerprint: 82.113.146.227 xdebug.org Received: from [82.113.146.227] ([82.113.146.227:35718] helo=xdebug.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BC/12-23587-329C1285 for ; Tue, 08 Nov 2016 07:46:28 -0500 Received: from localhost (localhost [IPv6:::1]) by xdebug.org (Postfix) with ESMTPS id 6F17310C011; Tue, 8 Nov 2016 12:46:25 +0000 (GMT) Date: Tue, 8 Nov 2016 12:46:25 +0000 (GMT) X-X-Sender: derick@whisky.home.derickrethans.nl To: Arjen Schol cc: PHP Developers Mailing List In-Reply-To: <46.92.05967.9AB91285@pb1.pair.com> Message-ID: References: <46.92.05967.9AB91285@pb1.pair.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Subject: Re: [PHP-DEV] DateTime microseconds discussion From: derick@php.net (Derick Rethans) On Tue, 8 Nov 2016, Arjen Schol wrote: > Hi, > > Support for microseconds was added late in the 7.1 RC cycle, however is has > some issues: Some *additional* support for microseconds was added in the PHP 7.1 cycle, mostly to support bug fixes that have been around for a long time. > > 1. There is no easy way to set microseconds to 0, you have to call setTime see > https://3v4l.org/YUhFF A setMicroseconds method would be handy and/or support > to relative strings to set microseconds to 0 (just like midnight does for > H:i:s). Or am I missing something? - You can't set just the seconds or minute portion alone either, through setTime(). Microseconds are just an extension of the time portion. - Using "midnight" also sets the microseconds to 0: [PHP: 7.1.0-dev ] derick@whisky:~ $ cat /tmp/midnight.php modify( 'midnight' ) ); ?> [PHP: 7.1.0-dev ] derick@whisky:~ $ php -n /tmp/midnight.php object(DateTimeImmutable)#1 (3) { ["date"]=> string(26) "2016-11-08 12:01:20.023680" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTimeImmutable)#2 (3) { ["date"]=> string(26) "2016-11-08 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } > 2. Microsecond support is useful, by not by default I think. Why not > introduce a 3rd parameter $with_microseconds/$set_microseconds which > defaults to false? A 3rd parameter to which function? > Or A second class DateTimeWithMicroseconds? Maybe not so fancy naming, > but it's very clear what will happen. But that would be a duplicate. The already existing DateTime and DateTimeImmutable classes already support microseconds. Adding an extra class for them, would just be confusing. > 3. The 4th parameter to setTime() should not cause BC breakage. Added additional new arguments with a default value, is not a BC break. cheers, Derick